--- /dev/null
+bin/pep8analysis:
+ mkdir -p bin
+ ../../bin/nitg --global -o bin/pep8analysis -I lib src/pep8analysis.nit
+
+doc/index.html:
+ ../../bin/nitdoc -I lib src/pep8analysis.nit
+
+tests: bin/pep8analysis
+ bin/pep8analysis --cfg-long tests/privat/*.pep tests/laf/*.pep tests/terrasa/*.pep
+
+.PHONY: bin/pep8analysis tests doc/index.html
--- /dev/null
+# Pep/8 Analysis
+
+This project provides tools to statically analyze Pep/8 programs in order to detect bugs or bad programming practices.
+
+For more information about the Pep/8 assembly language visit http://code.google.com/p/pep8-1/.
+
+# Installation
+
+Make sure you have a Nit compiler installed (http://nitlanguage.org) and the environment variable NIT\_DIR correctly set to the Nit installation directory.
+
+Clone the source from http://github.com/xymus/pep8analysis.git and compile with `make`.
+
+# Usage
+
+For basic results, execute on the Pep/8 program prog.pep with `bin/pep8analyzer prog.pep`.
+
+Call `bin/pep8analyer --help` for a description of the available (and up to date) options.
+
+The tools provides its results in two ways, the final report and an annotated CFG (usually created in the out directory).
+
+# Analyses
+
+## Dead code and possible execution of data
+
+The tools analyses statically the program according to possbile branches and function calls to find wrongfully placed instructions and directives. It reports dead code blocks and possibly executed data blocks.
+
+## Range analysis
+
+The range analysis reports the value of registers and memory on the annotated CFG.
+
+## Reaching definitions
+
+The reaching definitions analysis tracks what lines may have assigned values to register and memory. Its results are on the anotated CFG. They can be used to better understand a program.
+
+## Types analysis
+
+The types analysis detects wrongful use of types or of uninitialized data. It reports possible errors in the final report.
--- /dev/null
+import rich_instructions
+import suffixed_instructions
+import pretty_instructions
+
--- /dev/null
+import backbone
+import parser
+
+redef class AnalysisManager
+ fun build_ast( filename : String ) : nullable AListing
+ do
+ var file = new IFStream.open( filename )
+
+ var source = new SourceFile(filename, file)
+ var lexer = new Lexer(source)
+ var parser = new Parser(lexer)
+ var node_tree = parser.parse
+
+ var ast = node_tree.n_base
+ if ast == null then
+ var err = node_tree.n_eof
+ assert err isa AError
+ print "error at {err.location}: {err.message}"
+ return null
+ end
+
+ return ast
+ end
+end
--- /dev/null
+module pretty_instructions
+
+import ast_base
+import rich_instructions
+
+redef class AnalysisManager
+ var opt_ast = new OptionBool("Print the AST","--ast")
+
+ redef init
+ do
+ super
+ opts.add_option(opt_ast)
+ end
+
+ redef fun build_ast(filename)
+ do
+ var ast = super
+
+ if ast != null and opt_ast.value then
+ var printer = new ASTPrinter
+ printer.enter_visit(ast)
+ print printer.str
+ end
+
+ return ast
+ end
+end
+
+class ASTPrinter
+ super Visitor
+
+ var str writable = ""
+
+ init do end
+ redef fun visit(n) do n.accept_ast_printer(self)
+end
+
+redef class ANode
+ fun accept_ast_printer(v: ASTPrinter) do visit_all(v)
+end
+
+redef class Token
+ redef fun to_s do return text
+ redef fun accept_ast_printer(v: ASTPrinter) do v.str += self.to_s # + " "
+end
+
+redef class TId
+ redef fun accept_ast_printer(v: ASTPrinter)
+ do
+ var len = self.to_s.length
+ if len < 6 and len > 1 then
+ v.str += self.to_s + " "*(6-len)
+ else
+ v.str += self.to_s
+ end
+ end
+end
+
+redef class ANonEmptyLine
+ redef fun accept_ast_printer(v: ASTPrinter)
+ do
+ if n_label_decl == null then v.str += once " "*10
+ visit_all(v)
+ end
+end
+
+redef class AInstruction
+ redef fun accept_ast_printer(v: ASTPrinter)
+ do
+ var pre_size = v.str.length
+ visit_all(v)
+ var post_size = v.str.length
+ var diff_size = post_size - pre_size
+ if diff_size < 20 then v.str += " "*(20-diff_size)
+ end
+end
+
+redef class ALabelDecl
+ redef fun accept_ast_printer(v: ASTPrinter)
+ do
+ var text = n_id.text + ":"
+ v.str += text + " "*(10-text.length)
+ end
+end
+
+redef class ALine
+ fun text: String
+ do
+ var p = new ASTPrinter
+ p.enter_visit( self )
+ return p.str
+ end
+end
--- /dev/null
+# Pep/8 instructions are not reserved as keywords. It is common
+# that the identifier of an instruction will be used for a label.
+# For this reason, we cannot create precise instruction nodes with
+# the parser.
+#
+# This module manually creates the expected subclass with an additionnal
+# OOP hiearchy.
+
+module rich_instructions
+
+import backbone
+intrude import parser
+import ast_base
+
+redef class AnalysisManager
+ redef fun build_ast(filename)
+ do
+ var ast = super
+ if ast != null then
+ #fun enrich_ast( ast : AListing ) do
+ for line in ast.n_lines do
+ if line isa AInstructionLine then
+ line.enrich
+ end
+ end
+ end
+ return ast
+ end
+end
+
+redef class AInstructionLine
+ # TODO move to AnalysisManager as private?
+ private fun enrich
+ do
+ var instr = n_instruction
+ var new_instr : AInstruction
+
+ var id = instr.n_id.text.to_upper
+ if instr isa ABinaryInstruction then
+ if id == "BR" then
+ new_instr = new ABrInstruction.from(instr)
+ else if id == "BRLE" then
+ new_instr = new ABrleInstruction.from(instr)
+ else if id == "BRLT" then
+ new_instr = new ABrltInstruction.from(instr)
+ else if id == "BREQ" then
+ new_instr = new ABreqInstruction.from(instr)
+ else if id == "BRNE" then
+ new_instr = new ABrneInstruction.from(instr)
+ else if id == "BRGE" then
+ new_instr = new ABrgeInstruction.from(instr)
+ else if id == "BRGT" then
+ new_instr = new ABrgtInstruction.from(instr)
+ else if id == "BRV" then
+ new_instr = new ABrvInstruction.from(instr)
+ else if id == "BRC" then
+ new_instr = new ABrcInstruction.from(instr)
+ else if id == "CALL" then
+ new_instr = new ACallInstruction.from(instr)
+ else if id == "NOP" then
+ new_instr = new ABinaryNopInstruction.from(instr)
+ else if id == "DECI" then
+ new_instr = new ADeciInstruction.from(instr)
+ else if id == "DECO" then
+ new_instr = new ADecoInstruction.from(instr)
+ else if id == "STRO" then
+ new_instr = new AStroInstruction.from(instr)
+ else if id == "CHARI" then
+ new_instr = new AChariInstruction.from(instr)
+ else if id == "CHARO" then
+ new_instr = new ACharoInstruction.from(instr)
+ else if id == "ADDSP" then
+ new_instr = new AAddspInstruction.from(instr)
+ else if id == "SUBSP" then
+ new_instr = new ASubspInstruction.from(instr)
+ else if id.has_prefix("ADD") then
+ new_instr = new AAddInstruction.from(instr)
+ else if id.has_prefix("SUB") then
+ new_instr = new ASubInstruction.from(instr)
+ else if id.has_prefix("AND") then
+ new_instr = new AAndInstruction.from(instr)
+ else if id.has_prefix("OR") then
+ new_instr = new AOrInstruction.from(instr)
+ else if id.has_prefix("CP") then
+ new_instr = new ACpInstruction.from(instr)
+ else if id.has_prefix("LDBYTE") then
+ new_instr = new ALdbyteInstruction.from(instr)
+ else if id.has_prefix("LD") then
+ new_instr = new ALdInstruction.from(instr)
+ else if id.has_prefix("STBYTE") then
+ new_instr = new AStbyteInstruction.from(instr)
+ else if id.has_prefix("ST") then
+ new_instr = new AStInstruction.from(instr)
+ else
+ # error
+ print "error {instr.location}: invalid instruction {id} with data access"
+ abort
+ end
+ else if instr isa AUnaryInstruction then
+ if id == "STOP" then
+ new_instr = new AStopInstruction.from(instr)
+ else if id == "RETTR" then
+ new_instr = new ARettrInstruction.from(instr)
+ else if id == "MOVSPA" then
+ new_instr = new AMovspaInstruction.from(instr)
+ else if id == "MOVFLGA" then
+ new_instr = new AMovflgaInstruction.from(instr)
+ else if id.has_prefix("NOT") then
+ new_instr = new ANotInstruction.from(instr)
+ else if id.has_prefix("NEG") then
+ new_instr = new ANegInstruction.from(instr)
+ else if id.has_prefix("ASL") then
+ new_instr = new AAslInstruction.from(instr)
+ else if id.has_prefix("ASR") then
+ new_instr = new AAsrInstruction.from(instr)
+ else if id.has_prefix("ROL") then
+ new_instr = new ARolInstruction.from(instr)
+ else if id.has_prefix("ROR") then
+ new_instr = new ARorInstruction.from(instr)
+ else if id.has_prefix("NOP") then
+ new_instr = new AUnaryNopInstruction.from(instr)
+ else if id.has_prefix("RET") then
+ new_instr = new ARetInstruction.from(instr)
+ else
+ # error
+ print "error {instr.location}: invalid instruction {id} without data access"
+ abort
+ end
+ else abort
+
+ # TODO check, one of those 2 might not be necessary
+ replace_child( instr, new_instr )
+ #n_instruction = new_instr
+ end
+end
+
+#
+# Support classes
+#
+abstract class ARichBinaryInstruction
+ super ABinaryInstruction
+
+ #redef var n_access : AAccess
+ #redef var n_id : TId
+
+ init from( src: ABinaryInstruction ) do
+ _n_operand = src.n_operand
+ _n_id = src.n_id
+ location = src.location
+ parent = src.parent
+ end
+end
+
+abstract class ARichUnaryInstruction
+ super AUnaryInstruction
+
+ #redef var n_id : TId
+
+ init from( src: AUnaryInstruction ) do
+ _n_id = src.n_id
+ _location = src.location
+ parent = src.parent
+ end
+end
+
+#
+# Categories
+#
+abstract class ABranchInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+
+class ABrInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ABrleInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ABrltInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ABreqInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ABrneInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ABrgeInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ABrgtInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ABrvInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ABrcInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+class ACallInstruction
+ super ABranchInstruction
+ init from( src ) do super
+end
+
+
+abstract class ANopInstruction
+ super AInstruction
+end
+class ABinaryNopInstruction
+ super ANopInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+class AUnaryNopInstruction
+ super ANopInstruction
+ super ARichUnaryInstruction
+ init from( src ) do super
+end
+
+
+abstract class AOutputInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+abstract class AInputInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+# TODO add category for ADecInstruction?
+class ADeciInstruction
+ super AInputInstruction
+ init from( src ) do super
+end
+class ADecoInstruction
+ super AOutputInstruction
+ init from( src ) do super
+end
+
+class AStroInstruction
+ super AOutputInstruction
+ init from( src ) do super
+end
+
+class AChariInstruction
+ super AInputInstruction
+ init from( src ) do super
+end
+class ACharoInstruction
+ super AOutputInstruction
+ init from( src ) do super
+end
+
+
+abstract class AStackInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+class AAddspInstruction
+ super AStackInstruction
+ init from( src ) do super
+end
+class ASubspInstruction
+ super AStackInstruction
+ init from( src ) do super
+end
+
+# Misc
+class AStopInstruction
+ super ARichUnaryInstruction
+ init from( src ) do super
+end
+
+class ARettrInstruction
+ super ARichUnaryInstruction
+ init from( src ) do super
+end
+
+abstract class AMovInstruction
+ super ARichUnaryInstruction
+ init from( src ) do super
+end
+class AMovspaInstruction
+ super AMovInstruction
+ init from( src ) do super
+end
+class AMovflgaInstruction
+ super AMovInstruction
+ init from( src ) do super
+end
+
+
+class ANotInstruction
+ super ARichUnaryInstruction
+ init from( src ) do super
+end
+
+class ANegInstruction
+ super ARichUnaryInstruction
+ init from( src ) do super
+end
+
+abstract class AShiftInstruction
+ super ARichUnaryInstruction
+ init from( src ) do super
+end
+class AAslInstruction
+ super AShiftInstruction
+ init from( src ) do super
+end
+class AAsrInstruction
+ super AShiftInstruction
+ init from( src ) do super
+end
+class ARolInstruction
+ super AShiftInstruction
+ init from( src ) do super
+end
+class ARorInstruction
+ super AShiftInstruction
+ init from( src ) do super
+end
+
+class ARetInstruction
+ super ARichUnaryInstruction
+ init from( src ) do super
+end
+
+
+# TODO find a better name
+abstract class AArithmeticInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+class AAddInstruction
+ super AArithmeticInstruction
+ init from( src ) do super
+end
+class ASubInstruction
+ super AArithmeticInstruction
+ init from( src ) do super
+end
+class AAndInstruction
+ super AArithmeticInstruction
+ init from( src ) do super
+end
+class AOrInstruction
+ super AArithmeticInstruction
+ init from( src ) do super
+end
+
+class ACpInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+
+
+abstract class ALoadInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+class ALdInstruction
+ super ALoadInstruction
+ init from( src ) do super
+end
+class ALdbyteInstruction
+ super ALoadInstruction
+ init from( src ) do super
+end
+
+abstract class AStoreInstruction
+ super ARichBinaryInstruction
+ init from( src ) do super
+end
+class AStInstruction
+ super AStoreInstruction
+ init from( src ) do super
+end
+class AStbyteInstruction
+ super AStoreInstruction
+ init from( src ) do super
+end
--- /dev/null
+# Pep/8 instructions are not reserved as keywords. It is common
+# that the identifier of an instruction will be used for a label.
+# For this reason, we cannot create precise instruction nodes with
+# the parser.
+#
+# This module manually creates the expected subclass with an additionnal
+# OOP hiearchy.
+
+module suffixed_instructions
+
+import rich_instructions
+
+#
+# Support classes
+#
+abstract class ARegisterSuffixed
+ super AInstruction
+
+ fun register : Char do return n_id.text.to_upper.last
+end
+
+abstract class ADigitSuffixed
+ super AInstruction
+
+ fun digit : Int do return n_id.text.last.to_i
+ fun digit_max : Int is abstract
+end
+
+
+#
+# Other classification
+#
+redef class AUnaryNopInstruction
+ super ADigitSuffixed
+ redef fun digit_max do return 1.lshift(2)-1
+end
+
+redef class ANotInstruction
+ super ARegisterSuffixed
+end
+
+redef class ANegInstruction
+ super ARegisterSuffixed
+end
+
+redef class AShiftInstruction
+ super ARegisterSuffixed
+end
+
+redef class ARetInstruction
+ super ADigitSuffixed
+ redef fun digit_max do return 1.lshift(3)-1
+end
+
+redef abstract class AArithmeticInstruction
+ super ARegisterSuffixed
+end
+
+redef abstract class ALoadInstruction
+ super ARegisterSuffixed
+end
+
+redef abstract class AStoreInstruction
+ super ARegisterSuffixed
+end
--- /dev/null
+import opts
+
+import parser
+
+class AnalysisManager
+ super Noter
+ var opts = new OptionContext
+
+ init do end
+end
+
+abstract class Noter
+ var notes = new Array[Note]
+
+ var failed = false
+
+ fun print_notes
+ do
+ if not notes.is_empty then
+ print "# Notes:"
+ for n in notes do print n
+ end
+ end
+
+ fun fatal_error(n: ANode, msg: String)
+ do
+ notes.add( new Fatal(n.location, msg) )
+ failed = true
+ end
+
+ fun reset
+ do
+ failed = false
+ end
+end
+
+abstract class Note
+ var line: Location
+ var to: nullable Location = null
+ var msg: String
+
+ init (line: Location, msg: String)
+ do
+ self.line = line
+ self.msg = msg
+ end
+ init range(from, to: Location, msg: String)
+ do
+ self.line = from
+ self.to = to
+ self.msg = msg
+ end
+
+ fun prefix: String is abstract
+ redef fun to_s do
+ var s = ""
+ var to = to
+ if to != null then
+ s += " from {line} to {to}"
+ s = "{line.to_file_s}:{line.to_line_s}--{to.to_line_s}; "
+ else
+ s = "{line.to_file_s}:{line.to_line_s}; "
+ end
+ return "{prefix}{s}{msg}"
+ end
+end
+
+class Warn
+ super Note
+ init (line: Location, msg: String) do super
+ init range(from, to: Location, msg: String) do super
+ redef fun prefix do return "Warning: "
+end
+
+class Error
+ super Note
+ init (line: Location, msg: String) do super
+ init range(from, to: Location, msg: String) do super
+ redef fun prefix do return "Error: "
+end
+
+class Fatal
+ super Note
+ init (line: Location, msg: String) do super
+ init range(from, to: Location, msg: String) do super
+ redef fun prefix do return "Fatal: "
+end
+
+redef class Object
+ protected fun manager: AnalysisManager is abstract
+end
+
+redef class Location
+ # "line 5"
+ fun to_line_s: String
+ do
+ return line_start.to_s
+ end
+
+ fun to_file_s: String
+ do
+ return file.filename
+ end
+end
--- /dev/null
+import cfg_base
+import dot_printer
+import sanity
+
+redef class AnalysisManager
+ var opt_cfg = new OptionBool("Print the CFG to \"cfg.dot\" (for debugging purposes)", "--cfg")
+ var opt_cfg_long = new OptionBool("Print the long format CFG", "--cfg-long")
+
+ var opt_cfg_inline = new OptionBool("Inline function calls in the CFG", "--inline")
+ #var opt_cfg_not_inline = new OptionBool("Do not inline function calls in the CFG", "--no-inline")
+
+ var cfg: nullable CFG = null
+
+ redef init
+ do
+ super
+
+ opts.add_option(opt_cfg)
+ opts.add_option(opt_cfg_long)
+ #opts.add_option(opt_cfg_not_inline)
+ opts.add_option(opt_cfg_inline)
+ end
+
+ redef fun build_cfg(model)
+ do
+ var cfg = super
+ self.cfg = cfg
+
+ if cfg.has_function_calls then
+ #if not opt_cfg_not_inline.value then
+ if opt_cfg_inline.value then
+ cfg.inline_functions
+ else
+ cfg.watchdog = 0
+ var to_link = new List[BasicBlock]
+ if not cfg.link_ret_to_calls(cfg.start, to_link, new List[BasicBlock], 0) then
+ manager.fatal_error(model.lines.first, "failed to organize function calls")
+ end
+ end
+ end
+
+ if opt_cfg.value or opt_cfg_long.value then
+ var of = new OFStream.open("cfg.dot")
+ cfg.print_dot(of, opt_cfg_long.value)
+ of.close
+ end
+
+ verify_cfg_sanity(cfg)
+
+ return cfg
+ end
+end
--- /dev/null
+import pipeline
+
+import model
+
+redef class AnalysisManager
+ fun build_cfg( model: Model ) : CFG
+ do
+ var cfg = new CFG( model )
+ return cfg
+ end
+end
+
+redef class ABranchInstruction
+ fun is_indirect: Bool
+ do
+ var op = n_operand
+ return op isa AAnyOperand and (once ["x","d"]).has(op.addressing_mode)
+ end
+end
+
+class CFG
+ var start : BasicBlock
+ var finish : BasicBlock
+ var addr_to_blocks = new HashMap[Int,BasicBlock]
+ var blocks = new Array[BasicBlock]
+
+ var has_function_calls = false
+
+ init (model: Model)
+ do
+ assert not model.lines.is_empty
+
+ var starts = [0]
+ var ends = [model.lines.last.address]
+
+ # check for indirect branches
+ #var indirect_jump_sites = new Array[Int]
+ var has_indirect_jump_sites = false
+
+ # detect basic block limits
+ for line in model.lines do
+ if line isa AInstructionLine then
+ var instr = line.n_instruction
+ if instr isa ABranchInstruction then
+ if instr.is_indirect then
+ #indirect_jump_sites.add(line.address)
+ has_indirect_jump_sites = true
+ manager.notes.add(new Warn(instr.location, "use of indirect jumps, the CFG may be wrong"))
+ else
+ var op = instr.n_operand
+ var dest = op.n_value.to_i
+ starts.add(dest)
+ end
+ ends.add(line.address)
+ if not instr isa ABrInstruction then
+ # next line is possible start
+ starts.add(line.address+4)
+ end
+ else if instr isa AStopInstruction or
+ instr isa ARetInstruction then
+ ends.add(line.address)
+ end
+ end
+ end
+
+ var addresses_in_memory = new Array[Int]
+ #if not indirect_jumps.is_empty then
+ if has_indirect_jump_sites then
+ # find possible jump destinations
+
+ for line in model.lines do
+ if line isa ADirectiveLine then
+ var dir = line.n_directive
+ if dir isa AAddrssDirective then
+ var dest = dir.n_value.to_i
+ starts.add(dest)
+ addresses_in_memory.add(dest)
+ end
+ end
+ end
+
+ # link indirect jumps to possible destinations
+ #for src in addresses_in_memory do
+ #end
+ end
+
+ # sort breakpoints in order
+ starts = starts.uniq.sort_filter.to_a
+ ends = ends.uniq.sort_filter.to_a
+
+ # create basic blocks
+ var current_block: nullable BasicBlock = null
+ var next_start_i = 0
+ var next_end_i = 0
+ for line in model.lines do
+ var addr = line.address
+ while next_start_i < starts.length and
+ starts[next_start_i] < addr do next_start_i += 1
+ if next_start_i < starts.length and
+ starts[next_start_i] == addr then
+ # is a dest, and not already started
+ current_block = new BasicBlock
+ blocks.add(current_block)
+ end
+
+ if current_block == null then
+ current_block = new BasicBlock
+ blocks.add(current_block)
+ end
+
+ current_block.lines.add(line)
+
+ while next_end_i < ends.length and
+ ends[next_end_i] < addr do next_end_i += 1
+ if next_end_i < ends.length and
+ ends[next_end_i] == addr then
+ # stops here, unless already at the end
+ current_block = null
+ end
+ end
+
+ # adds created blocks to instance attribute
+ for b in blocks do
+ # save them in the class attribute
+ addr_to_blocks[b.lines.first.address] = b
+ end
+
+ # start node
+ start = new BasicBlock.start
+ blocks.add(start)
+ if blocks.length > 0 and blocks.first != start then
+ start.successors.add(blocks.first)
+ blocks.first.predecessors.add(start)
+ end
+ addr_to_blocks[-2] = start
+
+ # end node
+ finish = new BasicBlock.finish
+ blocks.add(finish)
+ addr_to_blocks[-1] = finish
+
+ # set successors and predecessors
+ for b in blocks do if not b.lines.is_empty then
+ var line = b.lines.last
+
+ if line isa AInstructionLine then
+ var instr = line.n_instruction
+ if instr isa ABranchInstruction then
+ var op = instr.n_operand
+ if instr.is_indirect then
+ for dest in addresses_in_memory do
+ var db = addr_to_blocks[dest]
+ b.successors.add(db)
+ db.predecessors.add(b)
+ end
+ else
+ var dest = op.n_value.to_i
+ var db = addr_to_blocks[dest]
+ b.successors.add(db)
+ db.predecessors.add(b)
+ end
+ end
+
+ if not instr isa ABrInstruction and
+ not instr isa AStopInstruction and
+ not instr isa ACallInstruction and
+ not instr isa ARetInstruction then
+ # next line is possible start
+ var dest = line.address+4
+ if addr_to_blocks.has_key(dest) then
+ var db = addr_to_blocks[dest]
+ b.successors.add(db)
+ db.predecessors.add(b)
+ else
+ manager.notes.add(new Error(line.location, "invalid line following instruction"))
+ end
+ end
+
+ if instr isa ACallInstruction then
+ has_function_calls = true
+ var next_addr = line.address+4
+ if not addr_to_blocks.has_key(next_addr) then
+ print "error, no instruction following call {b.name}"
+ else
+ b.after_call = addr_to_blocks[next_addr]
+ end
+ end
+
+ if b.successors.is_empty and
+ not instr isa ARetInstruction then
+ b.successors.add(finish)
+ finish.predecessors.add(b)
+ end
+ end
+ end
+
+ # Verify use of function calls
+ # To be by the book, each path from the start to the end should have
+ # the same number of calls and rets. There should never be more rets
+ # than calls.
+
+ # TODO check for instructions not in a path from start to end
+
+ # TODO check if branching on variable
+
+ # TODO check there is there is a consistant use of the stack between
+ # calls and rets.
+ end
+
+ # duplicate function calls
+ # at each call site, the tree representing the
+ fun inline_functions
+ do
+ inline_functions_recursive(start, new List[BasicBlock]) #0)
+
+ # retain only blocks reachble from start
+ var reachables = new HashSet[BasicBlock]
+ var todo = new Array[BasicBlock]
+ todo.add(start)
+ while not todo.is_empty do
+ var n = todo.pop
+ if not reachables.has(n) then
+ reachables.add(n)
+ for s in n.successors do if not reachables.has(s) then
+ todo.add(s)
+ end
+ end
+ end
+ self.blocks = reachables.to_a
+ end
+
+ private fun inline_functions_recursive(b: BasicBlock, seq: List[BasicBlock]) #depth: Int)
+ do
+ # Protection against cycles
+ #if depth > 1000 then return
+ var sl = seq.length
+ var loop_length = 3
+ if sl > loop_length then
+ for i in [0..sl-loop_length[ do
+ var same = true
+ for j in [0..loop_length[ do if seq[i+j]!=seq[sl-3+j] then
+ same = false
+ break
+ end
+
+ if same then
+ print "recursive since {seq[i].name}"
+ return
+ end
+ end
+ end
+ #if seq.has(b) then return
+
+ if not b.lines.is_empty then
+ var line = b.lines.last
+ if line isa AInstructionLine then
+ var instr = line.n_instruction
+ if instr isa ACallInstruction then
+ # replace called by a dup
+ assert b.successors.length == 1
+ var called = b.successors.first
+ var rets = new HashSet[BasicBlock]
+ var n = called.duplicate_tree(
+ new HashMap[BasicBlock,BasicBlock], rets, 0, blocks)
+ b.successors[0] = n
+ n.predecessors.add(b)
+
+ if b.after_call == null then
+ print "Already inlined"
+ return
+ else
+ # TODO bring back assert
+ if n.predecessors.length > 1 then
+ print "many pred"
+ print "n {n.name}"
+ print "preds {n.predecessors.join(" ")}"
+ end
+ assert n.predecessors.length == 1 else print n.predecessors.length
+ assert b.successors.length == 1
+ # TODO add information about duplicated block that are not dead
+
+ # link!
+ var next = b.after_call.as(not null)
+ # Another protection against cycles
+ for ret in rets do
+ ret.successors.add(next)
+ next.predecessors.add(ret)
+ end
+ #print "linking {b.name} to {next.name} ret len {rets.length}"
+
+ b.after_call = null
+ end
+ end
+ end
+ end
+
+ var si = 0
+ while si < b.successors.length do
+ var s = b.successors[si]
+ seq.add(s)
+ inline_functions_recursive(s, seq)
+ seq.pop
+ si+=1
+ end
+ end
+
+ var watchdog writable = 0
+ fun link_ret_to_calls(b: BasicBlock, to_link_ori: List[BasicBlock], seq: List[BasicBlock], depth: Int): Bool
+ do
+ watchdog += 1
+ if watchdog == 100000 then
+ print "Error: Umanagable cycle detected"
+ return false
+ end
+
+ var sl = seq.length
+ var loop_length = 4
+ if sl > loop_length then
+ for i in [0..sl-loop_length[ do
+ var same = true
+ for j in [0..loop_length[ do if seq[i+j]!=seq[sl-loop_length+j] then
+ same = false
+ break
+ end
+
+ if same then
+ #print "recursive since {seq[i].name}"
+ return true
+ end
+ end
+ end
+
+ # copy to_list
+ var to_link = new List[BasicBlock]
+ to_link.add_all(to_link_ori)
+
+ if not b.lines.is_empty then
+ var line = b.lines.last
+ if line isa AInstructionLine then
+ var instr = line.n_instruction
+ if instr isa ACallInstruction then
+ to_link.push(b)
+
+ else if instr isa ARetInstruction then
+ if to_link.is_empty then
+ manager.notes.add( new Error(instr.location,"no CALL can be linked to return") )
+ return false
+ else
+ var caller = to_link.pop
+ # link!
+ var next = caller.after_call.as(not null)
+
+ # Another protection against cycles
+ if b.successors.has(next) then return true
+
+ b.successors.add(next)
+ next.predecessors.add(b)
+ end
+ end
+ end
+ end
+
+ var si = 0
+ while si < b.successors.length do
+ var s = b.successors[si]
+ seq.add(s)
+ if not link_ret_to_calls(s, to_link,seq,depth+1) then return false
+ seq.pop
+ si+=1
+ end
+
+ return true # OK
+ end
+end
+
+class BasicBlock
+ var name : String
+ var lines = new Array[ANonEmptyLine]
+ var successors = new Array[BasicBlock]
+ var predecessors = new Array[BasicBlock]
+ var after_call : nullable BasicBlock = null
+
+ init
+ do
+ var count = (once new Counter).next
+ name = "b{count}"
+ end
+ init named(name: String) do self.name = name
+ init start do name = "start"
+ init finish
+ do
+ name = "end"
+ end
+
+ fun duplicate_tree(dups: HashMap[BasicBlock,BasicBlock],
+ rets: Set[BasicBlock], calls: Int,
+ blocks: Array[BasicBlock]) : BasicBlock
+ do
+ if dups.has_key(self) then return dups[self]
+
+ var n = new BasicBlock.from(self)
+ dups[self] = n
+ blocks.add(n)
+ n.successors = new Array[BasicBlock]
+ n.predecessors = new Array[BasicBlock]
+
+ if after_call != null then
+ var nac = after_call.duplicate_tree(dups, rets, calls, blocks)
+ n.after_call = nac
+ calls += 1 # for within that call
+ end
+
+ for s in successors do
+ var ns = s.duplicate_tree(dups, rets, calls, blocks)
+ n.successors.add(ns)
+ ns.predecessors.add(n)
+ end
+
+ if calls == 0 and successors.is_empty then rets.add(n)
+
+ return n
+ end
+
+ init from(o: BasicBlock)
+ do
+ var count = (once new Counter).next
+ name = "c{count}_from_{o.name}"
+ lines = o.lines
+ successors = o.successors
+ predecessors = o.predecessors
+ after_call = o.after_call
+ end
+end
+
+private class Counter
+ var count: Int = -1
+ fun next : Int
+ do
+ count += 1
+ return count
+ end
+end
--- /dev/null
+import cfg_base
+
+redef class CFG
+ fun print_dot( f: OFStream, long: Bool )
+ do
+ f.write("digraph \{\n")
+ f.write("charset=latin1\n")
+ f.write("node [shape=box,style=rounded,fontname=courier]\n")
+ for block in blocks do block.print_dot_nodes(f, long)
+ for block in blocks do block.print_dot_edges(f, long)
+ f.write("\}")
+ end
+end
+
+redef class BasicBlock
+ fun print_dot_nodes( f: OFStream, long: Bool )
+ do
+ var lbl
+ if long then
+ lbl = "\"{name}:\\n{dot_node_text}\""
+ else
+ lbl = name
+ end
+ f.write( "{name} [label={lbl}]\n" )
+ end
+
+ fun dot_node_text : String
+ do
+ var code_lines = new Array[String]
+ for line in lines do code_lines.add(line.text)
+ var code = code_lines.join("")
+
+ code = code.replace("\n","\\l").replace("\"","\\\"").replace("\\n","|n").replace("/","\\/").replace("\r","")
+ # the last one is a hack
+ return "{dot_node_header}{code}{dot_node_footer}"
+ end
+
+ fun dot_node_header: String do return ""
+ fun dot_node_footer: String do return ""
+
+ fun print_dot_edges( f: OFStream, long: Bool )
+ do
+ for s in successors do
+ f.write( "{name} -> {s.name}\n" )
+ end
+ var n = after_call
+ if n != null then
+ f.write( "{name} -> {n.name} [style=\"dashed\"]\n" )
+ end
+ end
+end
--- /dev/null
+module sanity
+
+import cfg_base
+
+redef class BasicBlock
+ private var cfg_sanity_verified = false
+
+ # reports data in code
+ private fun verify_cfg_sanity_code(v: Noter, data_in_code: Array[ALine])
+ do
+ for line in lines do if line isa ADirectiveLine then
+ data_in_code.add(line)
+ end
+
+ cfg_sanity_verified = true
+ end
+
+ # reports code in data
+ private fun verify_cfg_sanity_data(v: Noter, dead_lines: Array[ALine])
+ do
+ for line in lines do if line isa AInstructionLine then
+ dead_lines.add(line)
+ end
+
+ cfg_sanity_verified = true
+ end
+end
+
+redef class AnalysisManager
+ fun verify_cfg_sanity(cfg: CFG)
+ do
+ # verify executable code
+ var executed_data = new Array[ALine]
+ verify_cfg_sanity_recursively_code( cfg.start, executed_data )
+
+ # verify data or dead code
+ var dead_code = new Array[ALine]
+ for b in cfg.blocks do if not b.cfg_sanity_verified then
+ b.verify_cfg_sanity_data(self, dead_code)
+ end
+
+ group( dead_code, "unreachable instructions", false )
+ group( executed_data, "data in program flow", true )
+ end
+
+ fun verify_cfg_sanity_recursively_code(b: BasicBlock, executed_data: Array[ALine])
+ do
+ if b.cfg_sanity_verified then return # is code
+
+ b.verify_cfg_sanity_code(self,executed_data)
+ for s in b.successors do verify_cfg_sanity_recursively_code( s, executed_data )
+ end
+
+ private fun group(lines: Array[ALine], msg: String, error: Bool)
+ do
+ lines = lines.sort_filter.to_a
+ var len = lines.length
+ var first: nullable ALine = null
+ for i in [0..len[ do
+ var line = lines[i]
+ if first == null then
+ first = line
+ end
+ if i == len-1 or line.address + line.size != lines[i+1].address then
+ if error then
+ if first == line then
+ manager.notes.add(new Error(first.location, msg))
+ else
+ manager.notes.add(new Error.range(first.location, line.location, msg))
+ end
+ else
+ if first == line then
+ manager.notes.add(new Error(first.location, msg))
+ else
+ manager.notes.add(new Warn.range(first.location, line.location, msg))
+ end
+ end
+ first = null
+ end
+ end
+ end
+end
+
+redef class ALine
+ super Comparable
+ redef type OTHER: ALine
+ redef fun <=>(o) do return address <=> o.address
+end
--- /dev/null
+import framework
+
+import range
+import reaching_defs
+import types
--- /dev/null
+import cfg
+import advanced_collections
+
+class FlowAnalysis[S]
+ super Visitor
+
+ var current_in: nullable S writable
+ var current_out: nullable S writable
+
+ fun in_set(bb: BasicBlock): nullable S is abstract
+ fun out_set(bb: BasicBlock): nullable S is abstract
+ fun in_set=(bb: BasicBlock, s: S) is abstract
+ fun out_set=(bb: BasicBlock, s: S) is abstract
+
+ init
+ do
+ current_in = default_in_set
+ current_out = default_in_set
+ end
+
+ redef fun visit( node ) do node.visit_all(self)
+
+ # If false, it is a backwards analysis
+ fun is_forward: Bool is abstract
+
+ # ex: do return in1.union( in2 )
+ # ex: do return in1.intersection( in2 )
+ fun merge( in1, in2: nullable S): nullable S is abstract
+
+ fun default_in_set: nullable S do return null
+ fun empty_set: S is abstract
+
+ fun analyze(cfg: CFG)
+ do
+ # set defaults
+ var current_in: nullable S
+ var current_out: nullable S
+
+ # set current input as default start case
+ var todo = new List[BasicBlock]
+ todo.add_all(cfg.blocks)
+
+ # iterate until fixed point reached
+ while not todo.is_empty do
+
+ var block = todo.shift
+
+ if block == cfg.start then
+ continue
+ else if block.predecessors.is_empty then
+ # get default in (the most safe one)
+ current_in = default_in_set
+ else
+ current_in = out_set(block.predecessors.first)
+ for l in [1..block.predecessors.length[ do
+ var b = block.predecessors[l]
+ current_in = merge(current_in, out_set(b))
+ end
+ end
+
+ if current_in != null then
+ in_set(block) = current_in.as(not null)
+ else
+ continue
+ end
+
+ if block == cfg.finish then continue
+
+ var old_out = out_set(block)
+ for line in block.lines do
+ self.current_in = current_in.as(not null)
+ self.current_out = empty_set
+ pre_line_visit(line)
+ enter_visit(line)
+ post_line_visit(line)
+ current_out = self.current_out
+ current_in = self.current_out.as(not null)
+ #self.current_in = current_in
+ end
+
+ current_out = self.current_out
+ if old_out != current_out then
+ out_set(block) = current_out.as(not null)
+ if is_forward then
+ for b in block.successors do todo.add(b)
+ else
+ for b in block.predecessors do todo.add(b)
+ end
+ end
+ end
+ end
+
+ fun pre_line_visit(l: ALine) do end
+ fun post_line_visit(l: ALine) do end
+end
+
+class FineFlowAnalysis[V]
+ super FlowAnalysis[V]
+
+ redef fun in_set(bb)
+ do
+ if bb.lines.is_empty then return backup_in(bb)
+ return line_in( bb.lines.first )
+ end
+
+ redef fun in_set=(bb, v)
+ do
+ if bb.lines.is_empty then
+ backup_in(bb) = v
+ else line_in( bb.lines.first ) = v
+ end
+
+ redef fun out_set(bb)
+ do
+ if bb.lines.is_empty then return backup_out(bb)
+ return line_out( bb.lines.last )
+ end
+
+ redef fun out_set=(bb, v)
+ do
+ if bb.lines.is_empty then
+ backup_out(bb) = v
+ else line_out( bb.lines.last ) = v
+ end
+
+ fun backup_in(l: BasicBlock): nullable V is abstract
+ fun backup_out(l: BasicBlock): nullable V is abstract
+ fun backup_in=(l: BasicBlock, v: nullable V) is abstract
+ fun backup_out=(l: BasicBlock, v: nullable V) is abstract
+
+ fun line_in(l: ALine): nullable V is abstract
+ fun line_out(l: ALine): nullable V is abstract
+ fun line_in=(l: ALine, v: nullable V) is abstract
+ fun line_out=(l: ALine, v: nullable V) is abstract
+
+ redef fun pre_line_visit(line) do line_in(line) = current_in
+ redef fun post_line_visit(line) do line_out(line) = current_out
+end
+
+class StaticAnalysis[S]
+ super Visitor
+
+ var set: S
+ init (set: S) do self.set = set
+
+ redef fun visit( node ) do node.visit_all(self)
+ fun analyze(ast: AListing): S
+ do
+ enter_visit(ast)
+ return set
+ end
+end
--- /dev/null
+module range
+
+import framework
+
+# for linex, and should be used in the future
+import reaching_defs
+
+redef class AnalysisManager
+ fun do_range_analysis(ast: AListing, cfg: CFG)
+ do
+ var range_init_analysis = new InitRangeAnalysis(ast)
+ range_init_analysis.analyze(ast)
+
+ cfg.start.backup_ranges_out = range_init_analysis.set
+
+ var range_analysis = new RangeAnalysis
+ range_analysis.analyze(cfg)
+ end
+end
+
+class RangeAnalysis
+ super FineFlowAnalysis[RangeMap]
+
+ var current_range: nullable ValRange = null
+ var current_var: nullable Var = null
+
+ redef fun empty_set do return new RangeMap
+ redef fun is_forward do return true
+
+ init do super
+
+ redef fun visit(node)
+ do
+ node.accept_range_analysis(self,
+ current_in, current_out.as(not null))
+ end
+
+ # union
+ redef fun merge(a, b)
+ do
+ if a == null and b == null then return null
+ if a == null then return b.copy
+ if b == null then return a.copy
+
+ var n = new RangeMap
+ for k, v in a do
+ if b.has_key(k) then
+ # merge ranges
+ var u = b[k]
+ n[k] = new ValRange(v.min.min(u.min), v.max.max(u.max))
+ end
+ end
+
+ return n
+ end
+
+ redef fun line_in(line) do return line.ranges_in
+ redef fun line_out(line) do return line.ranges_out
+ redef fun line_in=(line, s) do line.ranges_in = s
+ redef fun line_out=(line, s) do line.ranges_out = s
+
+ redef fun backup_in(bb) do return bb.backup_ranges_in
+ redef fun backup_out(bb) do return bb.backup_ranges_out
+ redef fun backup_in=(bb, s) do bb.backup_ranges_in = s
+ redef fun backup_out=(bb, s) do bb.backup_ranges_out = s
+end
+
+class InitRangeAnalysis
+ super StaticAnalysis[RangeMap]
+
+ var current_line: ALine
+
+ init(prog: AListing)
+ do
+ super( new RangeMap )
+ current_line = prog.n_lines.first
+ end
+ redef fun visit(node)
+ do
+ if node isa ALine then current_line = node
+ node.accept_init_range_analysis(self, set)
+ end
+end
+
+redef class ALine
+ var ranges_in: nullable RangeMap = null
+ var ranges_out: nullable RangeMap = null
+end
+
+redef class BasicBlock
+ var backup_ranges_in: nullable RangeMap = null
+ var backup_ranges_out: nullable RangeMap = null
+
+ redef fun dot_node_header
+ do
+ if backup_ranges_in != null then
+ return "{super}-- ranges in = {backup_ranges_in.as(not null)}\\l"
+ else if not lines.is_empty and lines.first.ranges_in != null then
+ return "{super}-- ranges in = {lines.first.ranges_in.as(not null)}\\l"
+ else return super
+ end
+ redef fun dot_node_footer
+ do
+ if backup_ranges_out != null then
+ return "{super}-- ranges out = {backup_ranges_out.as(not null)}\\l"
+ else if not lines.is_empty and lines.last.ranges_out != null then
+ return "{super}-- ranges out = {lines.last.ranges_out.as(not null)}\\l"
+ else return super
+ end
+end
+
+class ValRange
+ var min: Int
+ var max: Int
+ init(min, max: Int)
+ do
+ self.min = min
+ self.max = max
+ end
+ init from(o: ValRange)
+ do
+ self.min = o.min
+ self.max = o.max
+ end
+ init at(v: Int)
+ do
+ self.min = v
+ self.max = v
+ end
+
+ redef fun to_s do
+ if min == max then return min.to_s
+ return "[{min}..{max}]"
+ end
+
+ redef fun ==(o) do return o != null and o isa ValRange and
+ min == o.min and max == o.max
+
+ fun ponctual: Bool do return min == max
+end
+class RangeMap
+ super HashMap[Var, ValRange]
+ redef fun ==(o)
+ do
+ if o == null or not o isa RangeMap then return false
+ if o.length != length then return false
+
+ for k, v in self do if not o.has_key(k) or o[k] != v then return false
+
+ return true
+ end
+
+ fun copy: RangeMap
+ do
+ var c = new RangeMap
+ c.recover_with(self)
+ return c
+ end
+
+ redef fun to_s do return "\{{join(", ", ":")}\}"
+end
+
+redef class ANode
+ fun accept_range_analysis(v: RangeAnalysis,
+ ins: nullable RangeMap, outs: RangeMap) do visit_all(v)
+ fun accept_init_range_analysis(v: InitRangeAnalysis,
+ set: RangeMap) do visit_all(v)
+end
+
+redef class AInstruction
+ redef fun accept_range_analysis(v, ins, outs)
+ do
+ visit_all(v)
+ if ins != null then outs.recover_with(ins)
+ end
+end
+
+redef class ALoadInstruction
+ redef fun accept_range_analysis(v, ins, outs)
+ do
+ visit_all(v)
+
+ if ins != null then outs.recover_with(ins)
+ var variable = def_var
+ #var add = new RangeMap[Var, ValRange](variable,
+
+ # kill every set for variable
+ # (is automatic by HashMap)
+
+ if variable != null then
+ # gen (&kill)
+ var cr = v.current_range
+ if cr != null then
+ outs[variable] = cr
+ else
+ outs.keys.remove(variable)
+ end
+ end
+ v.current_range = null
+ end
+end
+
+redef class AStoreInstruction
+ redef fun accept_range_analysis(v, ins, outs)
+ do
+ visit_all(v)
+
+ if ins != null then outs.recover_with(ins)
+ var src = src_var # reg
+ var def = def_var # mem
+
+ if def != null then
+ if src != null and ins != null and ins.has_key(src) then # we know the source and dest
+ var cr = ins[src]
+ outs[def] = cr
+ else
+ outs.keys.remove(def)
+ end
+ end
+ end
+end
+
+redef class AInputInstruction
+ redef fun accept_range_analysis(v, ins, outs)
+ do
+ visit_all(v)
+
+ if ins != null then outs.recover_with(ins)
+
+ var def = def_var # mem
+
+ if def != null and outs.has_key(def) then
+ outs.keys.remove(def)
+ end
+
+ end
+end
+
+redef class AArithmeticInstruction
+ fun do_arithmetic(rv, rm: ValRange): nullable ValRange do return null
+
+ redef fun accept_range_analysis(v, ins, outs)
+ do
+ v.current_range = null
+ visit_all(v)
+
+ if ins != null then outs.recover_with(ins)
+
+ var reg = reg_var
+
+ var cr = v.current_range
+
+ if cr != null and ins.has_key(reg) then
+ # and ins.has_key(mem) then
+ var r = do_arithmetic(ins[reg], cr)
+
+ if r != null then
+ # this prevents infinite loops
+ # we assume that the max for a student program in 999
+ if r.max > 999 then r.max = 999
+ if r.min < -999 then r.min = -999
+
+ outs[reg] = r
+ else
+ outs.keys.remove(reg)
+ end
+ else
+ outs.keys.remove(reg)
+ end
+ end
+end
+
+redef class AAddInstruction
+ redef fun do_arithmetic(rv, rm) do return new ValRange(rv.min+rm.min, rv.max+rm.max)
+end
+
+redef class ASubInstruction
+ redef fun do_arithmetic(rv, rm) do return new ValRange(rv.min-rm.max, rv.max-rm.min)
+end
+
+redef class ANegInstruction
+ redef fun accept_range_analysis(v, ins, outs)
+ do
+ v.current_range = null
+ visit_all(v)
+
+ if ins != null then outs.recover_with(ins)
+
+ var reg = reg_var
+ if ins.has_key(reg) then
+ var rm = ins[reg]
+ outs[reg] = new ValRange(-rm.max, -rm.min)
+ end
+ end
+end
+
+redef class AAnyOperand
+ redef fun accept_range_analysis(v, ins, outs)
+ do
+ if addressing_mode == "i" then # immediate
+ v.current_var = null
+ v.current_range = new ValRange(n_value.to_i, n_value.to_i)
+ return
+ else if addressing_mode == "d" then # direct
+ var ci = v.current_in
+ var address = n_value.to_i
+ var variable = new MemVar(address)
+ v.current_var = variable
+ if ci != null and ci.has_key(variable) then
+ var value = ci[variable]
+ v.current_range = new ValRange(value.min, value.max)
+ return
+ end
+ end
+
+ v.current_range = null
+ end
+end
+
+redef class AMovInstruction
+ # Almost impossible to guess so, topped
+ redef fun accept_range_analysis(v, ins, outs)
+ do
+ v.current_range = null
+ visit_all(v)
+
+ if ins != null then outs.recover_with(ins)
+
+ var reg = new RegisterVar('A')
+ if outs.has_key(reg) then
+ outs.keys.remove(reg)
+ end
+ end
+end
+
+redef class AWordDirective
+ redef fun accept_init_range_analysis(v, set)
+ do
+ var variable = new MemVar(v.current_line.address)
+ var value = new ValRange.at(n_value.to_i)
+ set[variable] = value
+ end
+end
+
+redef class AByteDirective
+ redef fun accept_init_range_analysis(v, set)
+ do
+ var variable = new MemVar(v.current_line.address)
+ var value = new ValRange.at(n_value.to_i)
+ set[variable] = value
+ end
+end
--- /dev/null
+module reaching_defs
+
+import framework
+
+redef class AnalysisManager
+ fun do_reaching_defs_analysis(cfg: CFG)
+ do
+ cfg.start.backup_reaching_defs_out = new ReachingDefsMap
+ var reaching_defs_analysis = new ReachingDefsAnalysis
+ reaching_defs_analysis.analyze(cfg)
+ end
+end
+
+class ReachingDefsAnalysis
+ super FineFlowAnalysis[ReachingDefsMap]
+
+ init do end
+ redef fun is_forward do return true
+
+ redef fun visit( node )
+ do
+ node.accept_reaching_defs_analysis( self, current_in, current_out.as(not null) )
+ end
+ redef fun merge(a,b)
+ do
+ if a == null then return b
+ if b == null then return a
+ return a.union(b)
+ end
+
+ redef fun backup_in(bb) do return bb.backup_reaching_defs_in
+ redef fun backup_out(bb) do return bb.backup_reaching_defs_out
+ redef fun backup_in=(bb, v) do bb.backup_reaching_defs_in = v
+ redef fun backup_out=(bb, v) do bb.backup_reaching_defs_out = v
+
+ redef fun line_in(line) do return line.reaching_defs_in
+ redef fun line_out(line) do return line.reaching_defs_out
+ redef fun line_in=(line, v) do line.reaching_defs_in = v
+ redef fun line_out=(line, v) do line.reaching_defs_out = v
+
+ redef fun default_in_set do return new ReachingDefsMap
+ redef fun empty_set do return new ReachingDefsMap
+end
+
+redef class ANode
+ fun accept_reaching_defs_analysis(v: ReachingDefsAnalysis, ins: nullable ReachingDefsMap, outs: ReachingDefsMap) do visit_all(v)
+end
+
+redef class AInstruction
+ redef fun accept_reaching_defs_analysis(v, ins, outs)
+ do
+ if ins != null then outs.recover_with(ins)
+ end
+end
+
+redef class ALoadInstruction
+ redef fun accept_reaching_defs_analysis(v, ins, outs)
+ do
+ if ins != null then outs.recover_with(ins)
+
+ var variable = def_var
+ if variable != null then
+ # kill & gen
+ var set = new HashSet[ALine]
+ set.add(parent.as(ALine))
+ outs[variable] = set
+ else
+ # TODO top
+ end
+ end
+end
+
+redef class AStoreInstruction
+ redef fun accept_reaching_defs_analysis(v, ins, outs)
+ do
+ if ins != null then outs.recover_with(ins)
+
+ var variable = def_var
+ if variable != null then
+ # kill & gen
+ var set = new HashSet[ALine]
+ set.add(parent.as(ALine))
+ outs[variable] = set
+ else
+ # TODO top
+ end
+ end
+end
+
+class ReachingDefsMap
+ super HashMap[Var,Set[ALine]]
+
+ fun union(o: ReachingDefsMap): ReachingDefsMap
+ do
+ var n = new ReachingDefsMap
+ for k, v in self do
+ n[k] = new HashSet[ALine]
+ n[k].add_all(v)
+ end
+ for k, v in o do
+ if not n.has_key(k) then n[k] = new HashSet[ALine]
+ n[k].add_all(v)
+ end
+ return n
+ end
+
+ fun intersection(o: ReachingDefsMap): ReachingDefsMap
+ do
+ var n = new ReachingDefsMap
+ for k, v in self do if n.has_key(k) then n[k].add_all(v)
+ for k, v in o do if n.has_key(k) then n[k].add_all(v)
+ return n
+ end
+
+ redef fun to_s do return join(";", ":")
+
+ redef fun ==(o)
+ do
+ if o != null and o isa ReachingDefsMap then
+ if length != o.length then return false
+ for k,v in self do
+ if not o.has_key(k) then return false
+ var ok = o[k]
+ if v.length != ok.length then return false
+ for l in v do if not ok.has(l) then return false
+ end
+ return true
+ else
+ return false
+ end
+ end
+end
+
+redef class ALine
+ var reaching_defs_in: nullable ReachingDefsMap = null
+ var reaching_defs_out: nullable ReachingDefsMap = null
+end
+
+redef class BasicBlock
+ var backup_reaching_defs_in: nullable ReachingDefsMap = null
+ var backup_reaching_defs_out: nullable ReachingDefsMap = null
+
+ redef fun dot_node_header
+ do
+ if lines.is_empty then
+ if backup_reaching_defs_in != null then
+ return "{super}-- r defs in = \{{backup_reaching_defs_in.to_s}\}\\l"
+ end
+ else if lines.first.reaching_defs_in != null then return "{super}-- r defs in = \{{lines.first.reaching_defs_in.to_s}\}\\l"
+ return super
+ end
+ redef fun dot_node_footer
+ do
+ if lines.is_empty then
+ if backup_reaching_defs_out != null then
+ return "{super}-- r defs out = \{{backup_reaching_defs_out.to_s}\}\\l"
+ end
+ else if lines.first.reaching_defs_out != null then return "{super}-- r defs out = \{{lines.last.reaching_defs_out.to_s}\}\\l"
+ return super
+ end
+end
+
+# This is bad.
+redef class HashSet[E]
+ redef fun to_s do return join(",")
+end
--- /dev/null
+import pipeline
+import opts
+
+import framework
+import range
+
+redef class AnalysisManager
+ var opt_report_unknown_types = new OptionBool("Report unknown types", "--report-types-top")
+ fun report_unknown_types: Bool do return opt_report_unknown_types.value
+
+ redef init
+ do
+ super
+ opts.add_option(opt_report_unknown_types)
+ end
+
+ fun do_types_analysis(ast: AListing, cfg: CFG)
+ do
+ # find types at program init
+ var tia = new TypesInitAnalysis(ast)
+ tia.analyze(ast)
+
+ # evaluate types with program flow
+ cfg.start.backup_types_out = tia.set
+ var ta = new TypesAnalysis
+ ta.analyze(cfg)
+
+ # check for errors
+ var tc = new TypesChecker(ast)
+ tc.analyze(ast)
+ end
+end
+
+# Types 1st step, find state at program load
+# one pass over the AST
+class TypesInitAnalysis
+ super StaticAnalysis[TypesMap]
+
+ var current_line: ALine
+
+ init(prog: AListing)
+ do
+ super( new TypesMap )
+ current_line = prog.n_lines.first
+ end
+ redef fun visit(node)
+ do
+ if node isa ALine then current_line = node
+ node.accept_types_init_analysis(self, set)
+ end
+end
+
+# Types 2nd step, evaluate types evolution
+# one pass over the AST
+class TypesAnalysis
+ super FineFlowAnalysis[TypesMap]
+
+ redef fun empty_set do return new TypesMap
+ redef fun is_forward do return true
+
+ init do super
+
+ redef fun visit(node) do node.accept_types_analysis(self, current_in, current_out.as(not null))
+
+ redef fun merge(a, b)
+ do
+ if a == null then
+ if b == null then return null
+ return b.copy
+ end
+ if b == null then return a.copy
+ return a.intersection(b)
+ end
+
+ redef fun backup_in(bb) do return bb.backup_types_in
+ redef fun backup_out(bb) do return bb.backup_types_out
+ redef fun backup_in=(bb, v) do bb.backup_types_in = v
+ redef fun backup_out=(bb, v) do bb.backup_types_out = v
+
+ redef fun line_in(line) do return line.types_in
+ redef fun line_out(line) do return line.types_out
+ redef fun line_in=(line, v) do line.types_in = v
+ redef fun line_out=(line, v) do line.types_out = v
+end
+
+# Types 3rd step, verification
+# one pass over the AST
+class TypesChecker
+ super StaticAnalysis[TypesMap]
+
+ var current_line: ALine
+
+ init(prog: AListing)
+ do
+ super( new TypesMap )
+ current_line = prog.n_lines.first
+ end
+ redef fun visit(node)
+ do
+ if node isa ALine then current_line = node
+ node.accept_types_checker(self)
+ end
+end
+
+class TypesMap
+ type T: Char
+
+ # bits
+ # 'u' unset
+ # 's' set
+ var bs = new HashMap[Char,T]
+
+ # The type can be:
+ # 'u' for uninitialized
+ # '0' zeroed
+ # 'b' byte
+ # 'w' word begin
+ # 'W' word end
+ # 'c' executable code
+ # 'l' ascii
+ # 'a' address begin
+ # 'A' address end
+
+ # registers
+ var rs = new HashMap[Char,Array[T]]
+
+ # stack
+ var stack = new Array[T]
+
+ # mem
+ var mem = new HashMap[Int, T]
+
+ init
+ do
+ rs['A'] = new Array[T].with_items('u', 'u')
+ rs['X'] = new Array[T].with_items('u', 'u')
+ bs['N'] = 'u'
+ bs['Z'] = 'u'
+ bs['V'] = 'u'
+ bs['C'] = 'u'
+ end
+
+ fun memory(a: Int): T
+ do
+ if mem.has_key(a) then return mem[a]
+ return 'u'
+ end
+ fun memory=(a: Int, v: T) do mem[a] = v
+
+ fun copy_to(o: TypesMap)
+ do
+ for k,v in rs do for b in [0..1] do o.rs[k][b] = rs[k][b]
+ for k,v in bs do o.bs[k] = v
+ for f in stack do o.stack.add(f)
+ for k, v in mem do o.mem[k] = v
+ end
+ fun copy: TypesMap
+ do
+ var tm = new TypesMap
+ copy_to(tm)
+ return tm
+ end
+
+ fun intersection(o: TypesMap): TypesMap
+ do
+ var tm = new TypesMap
+ for k,v in rs do for b in [0..1] do
+ var v1 = o.rs[k][b]
+ var v2 = rs[k][b]
+ if v1 == v2 then
+ tm.rs[k][b] = v1
+ else tm.rs[k][b] = merge(v1, v2)
+ end
+
+ for k,v in bs do o.bs[k] = v
+ for f in stack do o.stack.add(f)
+
+ for k, v in mem do if o.mem.has_key(k) then
+ if v == o.mem[k] then
+ tm.mem[k] = v
+ else tm.mem[k] = merge(v, o.mem[k])
+ else tm.mem[k] = 't'
+ for k, v in o.mem do if not tm.mem.has_key(k) then
+ tm.mem[k] = 't'
+ end
+ return tm
+ end
+
+ fun merge(a, b: Char): Char
+ do
+ var c = [a,b]
+ if c.has('w') and c.has('0') then return 'w'
+ if c.has('W') and c.has('0') then return 'W'
+ return 't'
+ end
+
+ fun label_at(index: Int): nullable String
+ do
+ var ltl = manager.model.address_to_line
+ if ltl.has_key(index) then
+ var line = ltl[index]
+ return line.lbl
+ end
+ return null
+ end
+
+ redef fun to_s
+ do
+ var s = "regs:\{{rs.join(",",":")}\}, "
+ #s = "{s}bits:\{{bs.join(",",":")}\}, "
+ #s = "{s}stack:\{{stack.join(",")}\}, "
+
+ var blocks = new Array[String]
+ var block_begin: nullable Int = null
+ var block_end = 0
+ var block_type = ' '
+ for a in mem.keys.to_a.sort_filter do
+ var t = mem[a]
+ if block_begin != null and (block_type != t or block_end != a-1) then
+ var lbl = label_at(block_begin)
+ if lbl != null then
+ lbl = "{lbl}@"
+ else lbl = ""
+
+ if block_begin == block_end then
+ blocks.add("{lbl}{block_begin}:{block_type}")
+ else blocks.add("{lbl}[{block_begin}..{block_end}]:{block_type}")
+ block_begin = null
+ end
+
+ if block_begin == null then block_begin = a
+
+ block_type = t
+ block_end = a
+ end
+ if block_begin != null then
+ var lbl = label_at(block_begin)
+ if lbl != null then
+ lbl = "{lbl}@"
+ else lbl = ""
+
+ if block_begin == block_end then
+ blocks.add("{lbl}{block_begin}:{block_type}")
+ else blocks.add("{lbl}[{block_begin}..{block_end}]:{block_type}")
+ end
+ s = "{s}mem:\{{blocks.join(",")}\}"
+
+ return s
+ end
+
+ redef fun ==(o)
+ do
+ if o == null or not o isa TypesMap then return false
+ for r,v in rs do for i in [0..2[ do if o.rs[r][i] != v[i] then return false
+
+ if stack.length != o.stack.length then return false
+ for s in [0..stack.length[ do if o.stack[s] != stack[s] then return false
+
+ if mem.length != o.mem.length then return false
+ for k,v in mem do if not o.mem.has_key(k) or o.mem[k] != v then return false
+
+ return true
+ end
+end
+
+redef class ALine
+ var types_in: nullable TypesMap = null
+ var types_out: nullable TypesMap = null
+end
+
+redef class BasicBlock
+ var backup_types_in: nullable TypesMap = null
+ var backup_types_out: nullable TypesMap = null
+
+ redef fun dot_node_header
+ do
+ if lines.is_empty then
+ if backup_types_in != null then
+ return "{super}-- types = \{{backup_types_in.to_s}\}\\l"
+ end
+ else if lines.first.types_in != null then return "{super}-- types = \{{lines.first.types_in.to_s}\}\\l"
+ return super
+ end
+ redef fun dot_node_footer
+ do
+ if lines.is_empty then
+ if backup_types_out != null then
+ return "{super}-- types = \{{backup_types_out.to_s}\}\\l"
+ end
+ else if lines.first.types_out != null then return "{super}-- types = \{{lines.last.types_out.to_s}\}\\l"
+ return super
+ end
+end
+
+redef class ANode
+ fun accept_types_analysis(v: TypesAnalysis, ins: nullable TypesMap, outs: TypesMap) do visit_all(v)
+ fun accept_types_init_analysis(v: TypesInitAnalysis, set: TypesMap) do visit_all(v)
+ fun accept_types_checker(v: TypesChecker) do visit_all(v)
+end
+
+redef class AAnyOperand
+ redef fun to_var
+ do
+ var line = parent.parent.as(ALine)
+ var ranges = line.ranges_in
+ if ranges != null then
+ if addressing_mode == "n" then
+ var addr_pos = new MemVar(n_value.to_i)
+ if ranges.has_key(addr_pos) and ranges[addr_pos].ponctual then
+ var addr_var = ranges[addr_pos].min
+ return new MemVar(addr_var)
+ end
+ else if addressing_mode == "x" then
+ var addr_pos: Var = new RegisterVar('X')
+ if ranges.has_key(addr_pos) and ranges[addr_pos].ponctual then
+ var reg_val = ranges[addr_pos].min
+ return new MemVar(n_value.to_i+reg_val)
+ end
+ end
+ end
+ return super
+ end
+end
+
+redef class AInstruction
+ # does not change the set
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ ins.copy_to(outs)
+ end
+
+ # set the memory for the line as being code
+ redef fun accept_types_init_analysis(v, set)
+ do
+ for i in [0..4[ do set.memory(v.current_line.address+i) = 'c'
+ end
+
+ fun verify_word(content: Array[Char], mem_str: String)
+ do
+ #if content.count('u') == 2 then
+ # uninitialized data
+ #manager.notes.add(new Error(location, "use of uninitialized values in {mem_str}, got {long_content_name(content)}"))
+ if content[0] == 'W' or content[1] == 'w' then
+ manager.notes.add(new Warn(location, "use of deorganized word in {mem_str}, got {long_content_name(content)}"))
+ #else if (content[0] == 'w' and content[1] != 'W') or (content[1] == 'W' and content[0] != 'w') then
+ else if (content[0] == 'w') != (content[1] == 'W') then
+ manager.notes.add(new Warn(location, "use of partial word in {mem_str}, got {long_content_name(content)}"))
+ #else if content.count('u') == 1 then # partially unitialized, a bad sign
+ #manager.notes.add(new Warn(location, "use of partially uninitialized values in {mem_str}, got {long_content_name(content)}"))
+ else if content.count('t') == 2 then # uninitialized data
+ if manager.report_unknown_types then
+ manager.notes.add(new Warn(location, "use of values from unknown source in {mem_str}, got {long_content_name(content)}"))
+ end
+ else if content[0] == '0' and content[1] == 'b' then # byte only OK!
+ else if content[0] == '0' and content[1] == 'l' then # ASCII only OK?
+ else if content[0] == '0' and content[1] == '0' then # all zero OK!
+ else if content[0] == 'a' and content[1] == 'A' then # address OK!
+ else if content[0] != 'w' and content[1] != 'W' then
+ manager.notes.add(new Warn(location, "expected word in {mem_str}, got {long_content_name(content)}"))
+ end
+ end
+
+ # 'u' for uninitialized
+ # '0' zeroed
+ # 'b' byte
+ # 'w' word begin
+ # 'W' word end
+ # 'c' executable code
+ # 'l' ascii
+ # 'a' address begin
+ # 'A' address end
+ fun long_data_name(d: Char): String
+ do
+ if d == 'u' then return "uninitialized"
+ if d == '0' then return "zero"
+ if d == 'b' then return "byte"
+ if d == 'w' then return "1st byte of word"
+ if d == 'W' then return "2nd byte of word"
+ if d == 'c' then return "code"
+ if d == 'l' then return "ASCII"
+ if d == 'a' then return "1st byte of address"
+ if d == 'A' then return "2nd byte of address"
+ if d == 't' then return "top"
+ print "Unknown data type '{d}'"
+ abort
+ end
+
+ fun long_content_name(c: Array[Char]): String
+ do
+ if (c[0]=='w' or c[0]=='0') and c[1]=='W' then return "word"
+ if c[0]=='a' and c[1]=='A' then return "address"
+ if c[0]==c[1] then return "2x {long_data_name(c[0])}"
+ return "{long_data_name(c[0])} then {long_data_name(c[1])}"
+ end
+end
+
+
+## Section: directives
+
+redef class AByteDirective
+ redef fun accept_types_init_analysis(v, set)
+ do
+ set.memory(v.current_line.address) = 'b'
+ end
+end
+
+redef class AWordDirective
+ redef fun accept_types_init_analysis(v, set)
+ do
+ set.memory(v.current_line.address) = 'w'
+ set.memory(v.current_line.address+1) = 'W'
+ end
+end
+
+redef class AAsciiDirective
+ redef fun accept_types_init_analysis(v, set)
+ do
+ # TODO AOperand::data
+ for i in [0..data.length[ do
+ set.memory(v.current_line.address+i) = 'l'
+ end
+ end
+end
+
+redef class AAddrssDirective
+ redef fun accept_types_init_analysis(v, set)
+ do
+ set.memory(v.current_line.address ) = 'a'
+ set.memory(v.current_line.address+1) = 'A'
+ end
+end
+
+## Section: other instructions
+
+redef class ALdInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+
+ var op = n_operand
+ if op isa AAnyOperand and op.addressing_mode == "i" then
+ if op.n_value.to_i == 0 then
+ outs.rs[register][0] = '0'
+ outs.rs[register][1] = '0'
+ else
+ outs.rs[register][0] = 'w'
+ outs.rs[register][1] = 'W'
+ end
+ return
+ end
+
+ var mem = mem_var
+ if mem isa MemVar then
+ var content = [ins.memory(mem.index), ins.memory(mem.index+1)]
+ outs.rs[register][0] = content[0]
+ outs.rs[register][1] = content[1]
+ #outs.rs[register][0] = 'w'
+ #outs.rs[register][1] = 'W'
+ end
+ end
+end
+
+redef class ALdbyteInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+ # outs.rs[register][1] = 'b'
+ var mem = mem_var
+ if mem isa MemVar then
+ var content = ins.memory(mem.index)
+ #verify_word(content, "m{mem.index}")
+ outs.rs[register][1] = content
+ end
+ end
+end
+
+redef class AStInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+ #outs.mem[n_operand.n_value.to_i ] = 'w'
+ #outs.mem[n_operand.n_value.to_i+1] = 'W'
+ var mem = mem_var
+ if mem isa MemVar then
+ var content = ins.rs[register]
+ outs.mem[n_operand.n_value.to_i ] = content[0]
+ outs.mem[n_operand.n_value.to_i+1] = content[1]
+ end
+ end
+
+ redef fun accept_types_checker(v)
+ do
+ var ins = v.current_line.types_in
+ var mem = mem_var
+ if mem isa MemVar and ins != null then
+ var content = ins.rs[register]
+ if ins.memory(n_operand.n_value.to_i) == 'c' or
+ ins.memory(n_operand.n_value.to_i) == 'c' then
+ manager.notes.add(new Warn(location, "overwriting code at {mem} with {long_content_name(content)}"))
+ end
+ end
+ end
+end
+
+redef class AStbyteInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+ #outs.mem[n_operand.n_value.to_i] = 'b'
+ var mem = mem_var
+ if mem isa MemVar then
+ var content = ins.rs[register]
+ outs.mem[n_operand.n_value.to_i] = content[1]
+ end
+ end
+
+ redef fun accept_types_checker(v)
+ do
+ var ins = v.current_line.types_in
+ var mem = mem_var
+ if mem isa MemVar and ins != null then
+ var content = ins.rs[register]
+ if ins.memory(n_operand.n_value.to_i) == 'c' then
+ manager.notes.add(new Warn(location, "overwriting code at {mem} with {long_data_name(content[1])}"))
+ end
+ end
+ end
+end
+
+redef class AShiftInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+ end
+end
+
+redef class AArithmeticInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+ outs.rs[register][0] = 'w'
+ outs.rs[register][1] = 'W'
+ end
+
+ redef fun accept_types_checker(v)
+ do
+ var ins = v.current_line.types_in
+ if ins == null then return
+
+ # register
+ var content = ins.rs[register]
+ verify_word(content, "r{register}")
+
+ # memory source
+ var mem = mem_var
+ if mem isa MemVar then
+ content = [ins.memory(mem.index), ins.memory(mem.index+1)]
+ verify_word(content, "m{mem.index}")
+ end
+ end
+end
+
+redef class ADecoInstruction
+ redef fun accept_types_checker(v)
+ do
+ var ins = v.current_line.types_in
+ if ins == null then return
+
+ var mem = mem_var
+ if mem isa MemVar then
+ var content = [ins.memory(mem.index), ins.memory(mem.index+1)]
+ verify_word(content, "m{mem.index}")
+ end
+ end
+end
+
+redef class ADeciInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+ var mem = mem_var
+ if mem isa MemVar then
+ outs.mem[mem.index ] = 'w'
+ outs.mem[mem.index+1] = 'W'
+ end
+ end
+end
+
+redef class AOutputInstruction
+ fun verify_ascii(content: Char)
+ do
+ if content == 'u' then
+ manager.notes.add(new Warn(location, "use of uninitialized values"))
+ else if content != 'l' then
+ if content != 't' or manager.opt_report_unknown_types.value then
+ manager.notes.add(new Warn(location, "use of non-ascii types ({content})"))
+ end
+ end
+ end
+end
+
+redef class ACharoInstruction
+ redef fun accept_types_checker(v)
+ do
+ var ins = v.current_line.types_in
+ if ins == null then return
+
+ var mem = mem_var
+ if mem isa MemVar then
+ var content = ins.memory(mem.index)
+ verify_ascii(content)
+ end
+ end
+end
+
+redef class AStroInstruction
+ redef fun accept_types_checker(v)
+ do
+ var ins = v.current_line.types_in
+ if ins == null then return
+
+ var mem = mem_var
+ if mem isa MemVar then
+ var content = ins.memory(mem.index)
+ verify_ascii(content)
+ end
+ end
+end
+
+redef class AChariInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+ outs.mem[n_operand.n_value.to_i] = 'l'
+ end
+end
+
+redef class ABranchInstruction
+ redef fun accept_types_checker(v)
+ do
+ var ins = v.current_line.types_in
+ if ins == null then return
+
+ var mem = mem_var
+ if mem isa MemVar then
+ var content = [ins.memory(mem.index), ins.memory(mem.index+1)]
+ if content[0] != 'a' or content[1] != 'A' then
+ manager.notes.add(new Warn(location, "use of non-address data for branching, got {long_content_name(content)}"))
+ end
+ end
+ end
+end
+
+redef class AMovInstruction
+ redef fun accept_types_analysis(v, ins, outs)
+ do
+ super
+
+ outs.rs['A'][0] = 'w'
+ outs.rs['A'][1] = 'W'
+ end
+end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This module is used to model Nit source-file and locations in source-file
+module location
+
+# A raw text Nit source file
+class SourceFile
+ # The path of the source
+ var filename: String
+
+ # The content of the source
+ var string: String
+
+ # Create a new sourcefile using a filename and a stream
+ init(filename: String, stream: IStream)
+ do
+ self.filename = filename
+ string = stream.read_all
+ line_starts[0] = 0
+ end
+
+ # Create a new sourcefile using a dummy filename and a given content
+ init from_string(filename: String, string: String)
+ do
+ self.filename = filename
+ self.string = string
+ line_starts[0] = 0
+ end
+
+ # Position of each line start
+ var line_starts: Array[Int] = new Array[Int]
+end
+
+# A location inside a source file
+class Location
+ super Comparable
+ redef type OTHER: Location
+
+ var file: nullable SourceFile
+ var line_start: Int
+ var line_end: Int
+ var column_start: Int
+ var column_end: Int
+
+ init(f: nullable SourceFile, line_s: Int, line_e: Int, column_s: Int, column_e: Int) do
+ file = f
+ line_start = line_s
+ line_end = line_e
+ column_start = column_s
+ column_end = column_e
+ end
+
+ # The index in the start character in the source
+ fun pstart: Int do return file.line_starts[line_start-1] + column_start-1
+
+ # The index on the end character in the source
+ fun pend: Int do return file.line_starts[line_end-1] + column_end-1
+
+ # The verbatim associated text in the source-file
+ fun text: String
+ do
+ var res = self.text_cache
+ if res != null then return res
+ var l = self
+ var pstart = self.pstart
+ var pend = self.pend
+ res = l.file.string.substring(pstart, pend-pstart+1)
+ self.text_cache = res
+ return res
+ end
+
+ private var text_cache: nullable String
+
+ init with_file(f: SourceFile) do init(f,0,0,0,0)
+
+ redef fun ==(other: nullable Object): Bool do
+ if other == null then return false
+ if not other isa Location then return false
+
+ if other.file != file then return false
+ if other.line_start != line_start then return false
+ if other.line_end != line_end then return false
+ if other.column_start != column_start then return false
+ if other.column_end != column_end then return false
+
+ return true
+ end
+
+ fun located_in(loc: nullable Location): Bool do
+ if loc == null then return false
+
+ if line_start < loc.line_start then return false
+ if line_start > loc.line_end then return false
+
+ if line_end > loc.line_end then return false
+
+ if line_start == loc.line_start then
+ if column_start < loc.column_start then return false
+ if column_start > loc.column_end then return false
+ end
+
+ if line_end == loc.line_end and column_end > loc.column_end then return false
+
+ return true
+ end
+
+ redef fun to_s: String do
+ var file_part = ""
+ if file != null then
+ file_part = file.filename
+ if file.filename.length > 0 then file_part += ":"
+ end
+
+ if line_start == line_end then
+ if column_start == column_end then
+ return "{file_part}{line_start},{column_start}"
+ else
+ return "{file_part}{line_start},{column_start}--{column_end}"
+ end
+ else
+ return "{file_part}{line_start},{column_start}--{line_end},{column_end}"
+ end
+ end
+
+ fun relative_to(loc: nullable Location): String do
+ var relative: Location
+ if loc != null and loc.file == self.file then
+ relative = new Location(null, self.line_start, self.line_end, self.column_start, self.column_end)
+ else
+ relative = new Location(self.file, self.line_start, self.line_end, self.column_start, self.column_end)
+ end
+ return relative.to_s
+ end
+
+ redef fun <(other: OTHER): Bool do
+ if self == other then return false
+ if self.located_in(other) then return true
+ if other.located_in(self) then return false
+
+ if line_start != other.line_start then return line_start < other.line_start
+ if column_start != other.column_start then return column_start < other.column_start
+ if line_end != other.line_end then return line_end < other.line_end
+
+ return column_end < other.column_end
+ end
+
+ # Return the associated line with the location highlihted with color and a carret under the starting position
+ # `color` must be and terminal escape sequence used as `"{escape}[{color}m;"`
+ # * `"0;31"` for red
+ # * `"1;31"` for bright red
+ # * `"0;32"` for green
+ fun colored_line(color: String): String
+ do
+ var esc = 27.ascii
+ var def = "{esc}[0m"
+ var col = "{esc}[{color}m"
+
+ var l = self
+ var i = l.line_start
+ var line_start = l.file.line_starts[i-1]
+ var line_end = line_start
+ var string = l.file.string
+ while line_end+1 < string.length and string[line_end+1] != '\n' and string[line_end+1] != '\r' do
+ line_end += 1
+ end
+ var lstart = string.substring(line_start, l.column_start - 1)
+ var cend
+ if i != l.line_end then
+ cend = line_end - line_start + 1
+ else
+ cend = l.column_end
+ end
+ var lmid
+ var lend
+ if line_start + cend <= string.length then
+ lmid = string.substring(line_start + l.column_start - 1, cend - l.column_start + 1)
+ lend = string.substring(line_start + cend, line_end - line_start - cend + 1)
+ else
+ lmid = ""
+ lend = ""
+ end
+ var indent = new Buffer
+ for j in [line_start..line_start+l.column_start-1[ do
+ if string[j] == '\t' then
+ indent.add '\t'
+ else
+ indent.add ' '
+ end
+ end
+ return "\t{lstart}{col}{lmid}{def}{lend}\n\t{indent}^"
+ end
+end
+
--- /dev/null
+import ast
+
+import operands
+
+redef class ADirective
+ fun size: Int is abstract
+end
+redef class AByteDirective
+ redef fun size do return 1
+end
+redef class AWordDirective
+ redef fun size do return 2
+end
+redef class ABlockDirective
+ redef fun size do return n_value.to_i
+end
+redef class AAsciiDirective
+ fun data: String do return n_value.as(AStringValue).n_string.content
+ redef fun size do return data.length
+end
+redef class AAddrssDirective
+ redef fun size do return 2
+end
+redef class AEquateDirective
+ redef fun size do return 0
+end
+
--- /dev/null
+import backbone
+import ast
+
+import directives
+import operands
+import vars
+
+redef class AnalysisManager
+ var model: nullable Model = null
+ fun build_model(ast: AListing): Model
+ do
+ var model = new Model(ast)
+ self.model = model
+ return model
+ end
+end
+
+class Model
+ # lines to appear on the resulting program
+ var lines = new Array[ANonEmptyLine]
+
+ # labet to declaation line
+ var labels_to_line = new HashMap[String,ALine]
+ var labels_to_address = new HashMap[String,Int]
+
+ # from adress to line
+ var address_to_line = new HashMap[Int,ANonEmptyLine]
+
+ init (ast: AListing)
+ do
+ var offset = 0
+ for line in ast.n_lines do
+ # TODO if directive = equate
+ var label_decl = line.n_label_decl
+ if label_decl != null then
+ var lbl = label_decl.n_id
+ var label_name = lbl.text
+
+ if line isa ADirectiveLine and line.n_directive isa AEquateDirective then
+ # .EQUATE
+ labels_to_address[label_name] = line.n_directive.as(AEquateDirective).n_value.to_i
+ lbl.labels_to_address[label_name] = line.n_directive.as(AEquateDirective).n_value.to_i
+ else
+ labels_to_address[label_name] = offset
+ lbl.labels_to_address[label_name] = offset
+ end
+ end
+
+ line.address = offset
+
+ if line isa ANonEmptyLine and line.size > 0 then
+ lines.add( line )
+ address_to_line[offset] = line
+ end
+ offset += line.size
+ end
+
+ for lbl,address in labels_to_address do
+ if address_to_line.has_key(address) then
+ var line = address_to_line[address]
+ labels_to_line[lbl] = line
+ end
+ end
+ end
+end
+
+redef class ALine
+ var address: Int = -1
+
+ fun size: Int is abstract
+
+ redef fun to_s do return "L{address}"
+
+ redef fun text
+ do
+ var text = super
+ var size = size
+ if size > 0 then
+ return "L{location.to_line_s} (m{address}..{address+size}): {text}"
+ else
+ return "L{location.to_line_s}: {text}"
+ end
+ end
+
+ fun lbl: nullable String
+ do
+ var lbl_decl = n_label_decl
+ if lbl_decl != null then
+ var lbl = lbl_decl.n_id.text
+ return lbl
+ else return null
+ end
+end
+redef class AInstructionLine
+ redef fun size do return 4
+end
+redef class ADirectiveLine
+ redef fun size do return n_directive.size
+end
+redef class AEmptyLine
+ redef fun size do return 0
+end
+
+redef class MemVar
+ redef fun to_s do
+ var ltl = manager.model.address_to_line
+ if ltl.has_key(index) then
+ var line = ltl[index]
+ var lbl = line.lbl
+ if lbl != null then
+ return "{lbl}@m{index}"
+ end
+ end
+ return "m{index}"
+ end
+end
--- /dev/null
+import ast
+
+redef class AValue
+ fun to_i: Int is abstract
+end
+
+redef class ALabelValue
+ redef fun to_i do
+ if not n_id.labels_to_address.has_key(n_id.text) then
+ manager.fatal_error( self, "Label {n_id.text} used but not defined.")
+ return 0
+ else
+ return n_id.labels_to_address[n_id.text]
+ end
+ end
+end
+redef class TId
+ var labels_to_address: HashMap[String,Int] = (once new HashMap[String,Int])
+ #redef fun to_i: Int do return label_to_address[text]
+end
+
+redef class ANumberValue
+ redef fun to_i do return n_number.text.to_i
+end
+
+redef class ACharValue
+ redef fun to_i do return n_char.content.first.ascii
+end
+
+redef class AStringValue
+ # legal but no not recommended
+ redef fun to_i do return n_string.content.first.ascii
+end
+
+redef class AHexValue
+ #TODO
+ redef fun to_i do return n_hex.text.to_hex
+end
+
+redef class TString # TkBlock
+ fun content : String
+ do
+ return text.substring(1, text.length-2)
+ end
+end
+redef class TChar # TkAscii
+ fun content : String
+ do
+ return text.substring(1, text.length-2)
+ end
+end
--- /dev/null
+module vars
+
+import ast
+
+import operands
+
+class Var
+end
+
+class RegisterVar
+ super Var
+
+ init (register: Char) do self.register = register
+
+ var register: Char
+
+ redef fun to_s do return "r{register}"
+
+ redef fun ==(o) do return o isa RegisterVar and register == o.register
+ redef fun hash do return 128 + register.hash
+end
+
+class StackVar
+ super Var
+
+ init (offset: Int) do self.offset = offset
+
+ var offset: Int
+
+ redef fun ==(o) do return o isa StackVar and offset == o.offset
+ redef fun hash do return 512 + offset.hash
+end
+
+class MemVar
+ super Var
+
+ init (index: Int) do self.index = index
+
+ var index: Int
+
+ # need Object::AnalysisManager
+ #redef fun to_s is abstract
+
+ redef fun ==(o) do return o isa MemVar and index == o.index
+ redef fun hash do return 1024 + index.hash
+end
+
+redef class AInstruction
+ fun def_var: nullable Var is abstract
+ fun src_var: nullable Var is abstract
+end
+
+redef class ABinaryInstruction
+ fun mem_var: nullable Var do return n_operand.to_var
+end
+
+redef class ALoadInstruction
+ redef fun def_var do return new RegisterVar(register)
+ redef fun src_var do return n_operand.to_var
+end
+
+redef class AStoreInstruction
+ redef fun def_var do return n_operand.to_var
+ redef fun src_var do return new RegisterVar(register)
+end
+
+redef class AInputInstruction
+ redef fun def_var do return n_operand.to_var
+end
+
+redef class ARegisterSuffixed
+ fun reg_var: Var do return new RegisterVar(register)
+end
+
+redef class AArithmeticInstruction
+end
+
+redef class AOperand
+ fun to_var: nullable Var is abstract
+end
+
+redef class AImmediateOperand
+ redef fun to_var do return null
+end
+
+redef class AAnyOperand
+ fun addressing_mode: String do return n_id.text
+ redef fun to_var
+ do
+ if addressing_mode == "i" then
+ else if addressing_mode == "d" then
+ return new MemVar(n_value.to_i)
+ else if addressing_mode == "n" then
+ else if addressing_mode == "s" then
+ return new StackVar(n_value.to_i)
+ else if addressing_mode == "sf" then
+ else if addressing_mode == "x" then
+ else if addressing_mode == "sx" then
+ else if addressing_mode == "sxf" then
+ end
+
+ return null
+ end
+end
+
--- /dev/null
+This directory contains the nit parser. It is generated from a grammar for sablecc3 ( http://www.sablecc.org ).
+In order to generate nit parser, you need the alternate SableCC3 generator ( http://www.mare.ee/indrek/sablecc/ ).
+
+Contents:
+
+ fact_parser.pl: Script used to factorize parser.nit
+ Makefile: Update grammar and generate .nit files
+ nit.sablecc3xx: Extended sablecc3 grammar (see prescc.sh)
+ prescc.sh: Program to transform an extended sablecc3 to a standard one
+ parser_nodes.nit: token and nodes classes hierarchy used by the parser and the lexer
+ tables.nit, tables_nit.h: Interfaces to access the tables needed by the parser and the lexer
+ test_parser.nit:
+ xss/*.xss: alternate SableCC3 template files for the Nit language
+
+
+The following are generated but present to avoid the need of sablecc3:
+
+ lexer.nit: generated lexer
+ parser.nit: generated parser
+ parser_prod.nit: All production with generated visit methods
+ tables_nit.c: The tables needed by the parser and the lexer
+ parser_abs.nit: Raw generated token and nodes classes used to maintain coherence of parser_nodes.nit
+
+
+Other temp files produced by the Makefile:
+
+ .nit.sablecc3: Sablecc3 grammar after processing
+ .nit.sablecc3.dump: Dump of the grammar to improve sablecc3 multiple runs
+ .parser-nofact.nit: The parser generated by SableCC3 before factorization by fact_parser.pl
+
--- /dev/null
+#!/usr/bin/perl
+
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# fact_parser, a Sablecc postprocessor.
+#
+# Factorize comon actions in a generated sablecc parser file
+# Synopsys: fact_parser < infile > outfile
+
+use warnings;
+
+%actions = (); # body of an action -> id of the first action with this body
+%dupl = (); # id of a duplicate action -> id of the first action with this body
+
+@text = (); # Resulting file
+$start = 0; # current mode: 0=begin of file; 1=after an action; 2=inside an action
+$tot = 0; # original total number of actions
+$cpt = 0; # final total number of action
+while (<>) {
+ # Process the body of the action?
+ if ($start == 2) {
+ push @action, $_;
+ if (/ new (?!Array)/) { $has_new = 1; }
+ }
+
+ # Start a new action?
+ if (/private class ReduceAction(\d+)/) {
+ $tot++;
+ $start = 2;
+ $nb = $1; # Identifier of the action
+ $head = $_; # The declaration line
+ @action = (); # Body of the action
+ $has_new = 0; # Is a new something used?
+ }
+
+ # Process the begin of the file?
+ if ($start == 0) { push @text, $_; }
+
+ # End of an action?
+ if ($start == 2 and /^end/) {
+ # Build the action body by filtering useless new
+ $action = "";
+ foreach $l (@action) {
+ if ($has_new or $l !~ / isa (?!Array)/) { $action .= $l; }
+ }
+
+ # Is it an original action?
+ if (not defined $actions{$action}) {
+ # Yes, so register it
+ $actions{$action} = $nb;
+ push @text, $head, $action;
+ $cpt++;
+ } else {
+ # No, so link the duplicate to the original
+ $mainnb = $actions{$action};
+ $dupl{$nb} = $mainnb;
+ }
+ $start = 1;
+ }
+}
+
+# Substitute duplicate actions with the originals in the whole file
+foreach (@text) {
+ if (/ReduceAction(\d+)/ && defined $dupl{$1}) {
+ $d = $dupl{$1};
+ s/$1/$d/;
+ }
+}
+
+print STDERR "* fact_parser: $tot -> $cpt\n";
+
+print @text;
--- /dev/null
+# Lexer and its tokens.
+# This file was generated by SableCC (http://www.sablecc.org/).
+module lexer
+
+intrude import parser_nodes
+private import tables
+
+redef class Token
+ var _text: nullable String
+
+ redef fun text
+ do
+ var res = _text
+ if res != null then return res
+ res = location.text
+ _text = res
+ return res
+ end
+
+ fun parser_index: Int is abstract
+end
+
+redef class TEol
+ redef fun parser_index: Int
+ do
+ return 0
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TNumber
+ redef fun parser_index: Int
+ do
+ return 1
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TFloat
+ redef fun parser_index: Int
+ do
+ return 2
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TChar
+ redef fun parser_index: Int
+ do
+ return 3
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TString
+ redef fun parser_index: Int
+ do
+ return 4
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class THex
+ redef fun parser_index: Int
+ do
+ return 5
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TColon
+ redef fun parser_index: Int
+ do
+ return 6
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TComma
+ redef fun parser_index: Int
+ do
+ return 7
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TComment
+ redef fun parser_index: Int
+ do
+ return 8
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TTkByte
+ redef fun parser_index: Int
+ do
+ return 9
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TTkWord
+ redef fun parser_index: Int
+ do
+ return 10
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TTkBlock
+ redef fun parser_index: Int
+ do
+ return 11
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TTkAscii
+ redef fun parser_index: Int
+ do
+ return 12
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TTkAddrss
+ redef fun parser_index: Int
+ do
+ return 13
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TTkEquate
+ redef fun parser_index: Int
+ do
+ return 14
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TTkBurn
+ redef fun parser_index: Int
+ do
+ return 15
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TEndBlock
+ redef fun parser_index: Int
+ do
+ return 16
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+redef class TId
+ redef fun parser_index: Int
+ do
+ return 17
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+
+redef class EOF
+ redef fun parser_index: Int
+ do
+ return 18
+ end
+
+ init(loc: Location)
+ do
+ _text = ""
+ _location = loc
+ end
+end
+
+redef class AError
+ readable var _message: String
+
+ init init_error(message: String, loc: Location)
+ do
+ init(loc)
+ _message = message
+ end
+end
+
+
+# The lexer extract NIT tokens from an input stream.
+# It is better user with the Parser
+class Lexer
+ super TablesCapable
+ # Last peeked token
+ var _token: nullable Token
+
+ # Lexer current state
+ var _state: Int = 0
+
+ # The source file
+ readable var _file: SourceFile
+
+ # Current character in the stream
+ var _stream_pos: Int = 0
+
+ # Current line number in the input stream
+ var _line: Int = 0
+
+ # Current column in the input stream
+ var _pos: Int = 0
+
+ # Was the last character a cariage-return?
+ var _cr: Bool = false
+
+ # Constante state values
+ private fun state_initial: Int do return 0 end
+
+ # Create a new lexer for a stream (and a name)
+ init(file: SourceFile)
+ do
+ _file = file
+ end
+
+ # Give the next token (but do not consume it)
+ fun peek: Token
+ do
+ while _token == null do
+ _token = get_token
+ end
+ return _token.as(not null)
+ end
+
+ # Give and consume the next token
+ fun next: Token
+ do
+ var result = _token
+ while result == null do
+ result = get_token
+ end
+ _token = null
+ return result
+ end
+
+ # Get a token, or null if it is discarded
+ private fun get_token: nullable Token
+ do
+ var dfa_state = 0
+
+ var sp = _stream_pos
+ var start_stream_pos = sp
+ var start_pos = _pos
+ var start_line = _line
+ var string = _file.string
+ var string_len = string.length
+
+ var accept_state = -1
+ var accept_token = -1
+ var accept_length = -1
+ var accept_pos = -1
+ var accept_line = -1
+
+ loop
+ if sp >= string_len then
+ dfa_state = -1
+ else
+ var c = string[sp].ascii
+ sp += 1
+
+ var cr = _cr
+ var line = _line
+ var pos = _pos
+ if c == 10 then
+ if cr then
+ cr = false
+ _file.line_starts[line] = sp
+ else
+ line = line + 1
+ pos = 0
+ _file.line_starts[line] = sp
+ end
+ else if c == 13 then
+ line = line + 1
+ pos = 0
+ cr = true
+ _file.line_starts[line] = sp
+ else
+ pos = pos + 1
+ cr = false
+ end
+
+ loop
+ var old_state = dfa_state
+ if dfa_state < -1 then
+ old_state = -2 - dfa_state
+ end
+
+ dfa_state = -1
+
+ var low = 0
+ var high = lexer_goto(old_state, 0) - 1
+
+ if high >= 0 then
+ while low <= high do
+ var middle = (low + high) / 2
+ var offset = middle * 3 + 1 # +1 because length is at 0
+
+ if c < lexer_goto(old_state, offset) then
+ high = middle - 1
+ else if c > lexer_goto(old_state, offset+1) then
+ low = middle + 1
+ else
+ dfa_state = lexer_goto(old_state, offset+2)
+ break
+ end
+ end
+ end
+ if dfa_state > -2 then break
+ end
+
+ _cr = cr
+ _line = line
+ _pos = pos
+ end
+
+ if dfa_state >= 0 then
+ var tok = lexer_accept(dfa_state)
+ if tok != -1 then
+ accept_state = dfa_state
+ accept_token = tok
+ accept_length = sp - start_stream_pos
+ accept_pos = _pos
+ accept_line = _line
+ end
+ else
+ if accept_state != -1 then
+ var location = new Location(_file, start_line + 1, accept_line + 1, start_pos + 1, accept_pos)
+ _pos = accept_pos
+ _line = accept_line
+ _stream_pos = start_stream_pos + accept_length
+ if accept_token == 0 then
+ return null
+ end
+ if accept_token == 1 then
+ return new TEol.init_tk(location)
+ end
+ if accept_token == 2 then
+ return new TNumber.init_tk(location)
+ end
+ if accept_token == 3 then
+ return new TFloat.init_tk(location)
+ end
+ if accept_token == 4 then
+ return new TChar.init_tk(location)
+ end
+ if accept_token == 5 then
+ return new TString.init_tk(location)
+ end
+ if accept_token == 6 then
+ return new THex.init_tk(location)
+ end
+ if accept_token == 7 then
+ return new TColon.init_tk(location)
+ end
+ if accept_token == 8 then
+ return new TComma.init_tk(location)
+ end
+ if accept_token == 9 then
+ return new TComment.init_tk(location)
+ end
+ if accept_token == 10 then
+ return new TTkByte.init_tk(location)
+ end
+ if accept_token == 11 then
+ return new TTkWord.init_tk(location)
+ end
+ if accept_token == 12 then
+ return new TTkBlock.init_tk(location)
+ end
+ if accept_token == 13 then
+ return new TTkAscii.init_tk(location)
+ end
+ if accept_token == 14 then
+ return new TTkAddrss.init_tk(location)
+ end
+ if accept_token == 15 then
+ return new TTkEquate.init_tk(location)
+ end
+ if accept_token == 16 then
+ return new TTkBurn.init_tk(location)
+ end
+ if accept_token == 17 then
+ return new TEndBlock.init_tk(location)
+ end
+ if accept_token == 18 then
+ return new TId.init_tk(location)
+ end
+ else
+ _stream_pos = sp
+ var location = new Location(_file, start_line + 1, start_line + 1, start_pos + 1, start_pos + 1)
+ if sp > start_stream_pos then
+ var text = string.substring(start_stream_pos, sp-start_stream_pos)
+ var token = new AError.init_error("Syntax error: unknown token {text}.", location)
+ return token
+ else
+ var token = new EOF(location)
+ return token
+ end
+ end
+ end
+ end
+ end
+end
+
--- /dev/null
+# Parser.
+# This file was generated by SableCC (http://www.sablecc.org/).
+module parser
+
+intrude import parser_prod
+import tables
+
+# State of the parser automata as stored in the parser stack.
+private class State
+ # The internal state number
+ readable writable var _state: Int
+
+ # The node stored with the state in the stack
+ readable writable var _nodes: nullable Object
+
+ init(state: Int, nodes: nullable Object)
+ do
+ _state = state
+ _nodes = nodes
+ end
+end
+
+class Parser
+ super TablesCapable
+ # Associated lexer
+ var _lexer: Lexer
+
+ # Stack of pushed states and productions
+ var _stack: Array[State]
+
+ # Position in the stack
+ var _stack_pos: Int
+
+ # Create a new parser based on a given lexer
+ init(lexer: Lexer)
+ do
+ _lexer = lexer
+ _stack = new Array[State]
+ _stack_pos = -1
+ build_reduce_table
+ end
+
+ # Do a transition in the automata
+ private fun go_to(index: Int): Int
+ do
+ var state = state
+ var low = 1
+ var high = parser_goto(index, 0) - 1
+
+ while low <= high do
+ var middle = (low + high) / 2
+ var subindex = middle * 2 + 1 # +1 because parser_goto(index, 0) is the length
+
+ var goal = parser_goto(index, subindex)
+ if state < goal then
+ high = middle - 1
+ else if state > goal then
+ low = middle + 1
+ else
+ return parser_goto(index, subindex+1)
+ end
+ end
+
+ return parser_goto(index, 2) # Default value
+ end
+
+ # Push someting in the state stack
+ private fun push(numstate: Int, list_node: nullable Object)
+ do
+ var pos = _stack_pos + 1
+ _stack_pos = pos
+ if pos < _stack.length then
+ var state = _stack[pos]
+ state.state = numstate
+ state.nodes = list_node
+ else
+ _stack.push(new State(numstate, list_node))
+ end
+ end
+
+ # The current state
+ private fun state: Int
+ do
+ return _stack[_stack_pos].state
+ end
+
+ # Pop something from the stack state
+ private fun pop: nullable Object
+ do
+ var res = _stack[_stack_pos].nodes
+ _stack_pos = _stack_pos -1
+ return res
+ end
+
+ # Build and return a full AST.
+ fun parse: Start
+ do
+ push(0, null)
+
+ var lexer = _lexer
+ loop
+ var token = lexer.peek
+ if token isa AError then
+ return new Start(null, token)
+ end
+
+ var state = self.state
+ var index = token.parser_index
+ var action_type = parser_action(state, 2)
+ var action_value = parser_action(state, 3)
+
+ var low = 1
+ var high = parser_action(state, 0) - 1
+
+ while low <= high do
+ var middle = (low + high) / 2
+ var subindex = middle * 3 + 1 # +1 because parser_action(state, 0) is the length
+
+ var goal = parser_action(state, subindex)
+ if index < goal then
+ high = middle - 1
+ else if index > goal then
+ low = middle + 1
+ else
+ action_type = parser_action(state, subindex+1)
+ action_value = parser_action(state, subindex+2)
+ break
+ end
+ end
+
+ if action_type == 0 then # SHIFT
+ push(action_value, lexer.next)
+ else if action_type == 1 then # REDUCE
+ _reduce_table[action_value].action(self)
+ else if action_type == 2 then # ACCEPT
+ var node2 = lexer.next
+ assert node2 isa EOF
+ var node1 = pop
+ assert node1 isa AListing
+ var node = new Start(node1, node2)
+ (new ComputeProdLocationVisitor).enter_visit(node)
+ return node
+ else if action_type == 3 then # ERROR
+ var node2 = new AError.init_error("Syntax error: unexpected {token}.", token.location)
+ var node = new Start(null, node2)
+ return node
+ end
+ end
+ end
+
+ var _reduce_table: Array[ReduceAction]
+ private fun build_reduce_table
+ do
+ _reduce_table = new Array[ReduceAction].with_items(
+ new ReduceAction0(0),
+ new ReduceAction1(0),
+ new ReduceAction2(0),
+ new ReduceAction3(0),
+ new ReduceAction4(1),
+ new ReduceAction5(1),
+ new ReduceAction6(1),
+ new ReduceAction7(1),
+ new ReduceAction8(1),
+ new ReduceAction9(1),
+ new ReduceAction10(1),
+ new ReduceAction11(1),
+ new ReduceAction12(1),
+ new ReduceAction13(1),
+ new ReduceAction14(1),
+ new ReduceAction15(1),
+ new ReduceAction16(2),
+ new ReduceAction17(3),
+ new ReduceAction18(3),
+ new ReduceAction19(4),
+ new ReduceAction20(4),
+ new ReduceAction21(5),
+ new ReduceAction22(5),
+ new ReduceAction23(5),
+ new ReduceAction24(5),
+ new ReduceAction25(5),
+ new ReduceAction26(6),
+ new ReduceAction27(6),
+ new ReduceAction28(6),
+ new ReduceAction29(6),
+ new ReduceAction30(6),
+ new ReduceAction31(6),
+ new ReduceAction32(6),
+ new ReduceAction33(7),
+ new ReduceAction34(7)
+ )
+ end
+end
+
+redef class Prod
+ # Location on the first token after the start of a production
+ # So outside the production for epilon production
+ var _first_location: nullable Location
+
+ # Location of the last token before the end of a production
+ # So outside the production for epilon production
+ var _last_location: nullable Location
+end
+
+# Find location of production nodes
+# Uses existing token locations to infer location of productions.
+private class ComputeProdLocationVisitor
+ super Visitor
+ # Currenlty visited productions that need a first token
+ var _need_first_prods: Array[Prod] = new Array[Prod]
+
+ # Already visited epsilon productions that waits something after them
+ var _need_after_epsilons: Array[Prod] = new Array[Prod]
+
+ # Already visited epsilon production that waits something before them
+ var _need_before_epsilons: Array[Prod] = new Array[Prod]
+
+ # Location of the last visited token in the current production
+ var _last_location: nullable Location = null
+
+ redef fun visit(n: nullable ANode)
+ do
+ if n == null then
+ return
+ else if n isa Token then
+ var loc = n.location
+ _last_location = loc
+
+ # Add a first token to productions that need one
+ if not _need_first_prods.is_empty then
+ for no in _need_first_prods do
+ no._first_location = loc
+ end
+ _need_first_prods.clear
+ end
+
+ # Find location for already visited epsilon production that need one
+ if not _need_after_epsilons.is_empty then
+ for no in _need_after_epsilons do
+ # Epsilon production that is in the middle of a non-epsilon production
+ # The epsilon production has both a token before and after it
+ var endl = loc
+ var startl = no._last_location
+ no.location = new Location(endl.file, startl.line_end, endl.line_start, startl.column_end, endl.column_start)
+ end
+ _need_after_epsilons.clear
+ end
+ else
+ assert n isa Prod
+ _need_first_prods.add(n)
+
+ var old_last = _last_location
+ _last_location = null
+ n.visit_all(self)
+ var endl = _last_location
+ if endl == null then _last_location = old_last
+
+ n._last_location = endl
+ var startl = n._first_location
+ if startl != null then
+ # Non-epsilon production
+ assert endl != null
+
+ n.location = new Location(startl.file, startl.line_start, endl.line_end, startl.column_start, endl.column_end)
+
+ if not _need_before_epsilons.is_empty then
+ var loc = new Location(startl.file, startl.line_start, startl.line_start, startl.column_start, startl.column_start)
+ for no in _need_before_epsilons do
+ # Epsilon production that starts the current non-epsilon production
+ no.location = loc
+ end
+ _need_before_epsilons.clear
+ end
+
+ if not _need_after_epsilons.is_empty then
+ var loc = new Location(endl.file, endl.line_end, endl.line_end, endl.column_end, endl.column_end)
+ for no in _need_after_epsilons do
+ # Epsilon production that finishes the current non-epsilon production
+ no.location = loc
+ end
+ _need_after_epsilons.clear
+ end
+ else
+ # No first token means epsilon production (or "throw all my tokens" production)
+ # So, it must be located it later
+ if endl == null then
+ # Epsilon production that starts a parent non-epsilon production
+ _need_before_epsilons.add(n)
+ else
+ # Epsilon production in the middle or that finishes a parent non-epsilon production
+ _need_after_epsilons.add(n)
+ end
+ end
+ end
+ end
+
+ init do end
+end
+
+# Each reduca action has its own class, this one is the root of the hierarchy.
+private abstract class ReduceAction
+ fun action(p: Parser) is abstract
+ fun concat(l1, l2 : Array[Object]): Array[Object]
+ do
+ if l1.is_empty then return l2
+ l1.append(l2)
+ return l1
+ end
+ var _goto: Int
+ init(g: Int) do _goto = g
+end
+
+private class ReduceAction0
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var listnode2 = new Array[Object]
+ var tendblocknode4 = nodearraylist1
+ assert tendblocknode4 isa nullable TEndBlock
+ var plistingnode1: nullable AListing = new AListing.init_alisting(
+ listnode2,
+ null,
+ tendblocknode4
+ )
+ node_list = plistingnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction1
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var listnode3 = new Array[Object]
+ var listnode2 = nodearraylist1
+ assert listnode2 isa Array[Object]
+ listnode3 = concat(listnode3, listnode2)
+ var tendblocknode5 = nodearraylist2
+ assert tendblocknode5 isa nullable TEndBlock
+ var plistingnode1: nullable AListing = new AListing.init_alisting(
+ listnode3,
+ null,
+ tendblocknode5
+ )
+ node_list = plistingnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction2
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var listnode2 = new Array[Object]
+ var plabeldeclnode3 = nodearraylist1
+ assert plabeldeclnode3 isa nullable ALabelDecl
+ var tendblocknode4 = nodearraylist2
+ assert tendblocknode4 isa nullable TEndBlock
+ var plistingnode1: nullable AListing = new AListing.init_alisting(
+ listnode2,
+ plabeldeclnode3,
+ tendblocknode4
+ )
+ node_list = plistingnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction3
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var listnode3 = new Array[Object]
+ var listnode2 = nodearraylist1
+ assert listnode2 isa Array[Object]
+ listnode3 = concat(listnode3, listnode2)
+ var plabeldeclnode4 = nodearraylist2
+ assert plabeldeclnode4 isa nullable ALabelDecl
+ var tendblocknode5 = nodearraylist3
+ assert tendblocknode5 isa nullable TEndBlock
+ var plistingnode1: nullable AListing = new AListing.init_alisting(
+ listnode3,
+ plabeldeclnode4,
+ tendblocknode5
+ )
+ node_list = plistingnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction4
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var teolnode4 = nodearraylist1
+ assert teolnode4 isa nullable TEol
+ var plinenode1: nullable AEmptyLine = new AEmptyLine.init_aemptyline(
+ null,
+ null,
+ teolnode4
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction5
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var plabeldeclnode2 = nodearraylist1
+ assert plabeldeclnode2 isa nullable ALabelDecl
+ var teolnode4 = nodearraylist2
+ assert teolnode4 isa nullable TEol
+ var plinenode1: nullable AEmptyLine = new AEmptyLine.init_aemptyline(
+ plabeldeclnode2,
+ null,
+ teolnode4
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction6
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var tcommentnode3 = nodearraylist1
+ assert tcommentnode3 isa nullable TComment
+ var teolnode4 = nodearraylist2
+ assert teolnode4 isa nullable TEol
+ var plinenode1: nullable AEmptyLine = new AEmptyLine.init_aemptyline(
+ null,
+ tcommentnode3,
+ teolnode4
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction7
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var plabeldeclnode2 = nodearraylist1
+ assert plabeldeclnode2 isa nullable ALabelDecl
+ var tcommentnode3 = nodearraylist2
+ assert tcommentnode3 isa nullable TComment
+ var teolnode4 = nodearraylist3
+ assert teolnode4 isa nullable TEol
+ var plinenode1: nullable AEmptyLine = new AEmptyLine.init_aemptyline(
+ plabeldeclnode2,
+ tcommentnode3,
+ teolnode4
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction8
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var pinstructionnode3 = nodearraylist1
+ assert pinstructionnode3 isa nullable AInstruction
+ var teolnode5 = nodearraylist2
+ assert teolnode5 isa nullable TEol
+ var plinenode1: nullable AInstructionLine = new AInstructionLine.init_ainstructionline(
+ null,
+ pinstructionnode3,
+ null,
+ teolnode5
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction9
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var plabeldeclnode2 = nodearraylist1
+ assert plabeldeclnode2 isa nullable ALabelDecl
+ var pinstructionnode3 = nodearraylist2
+ assert pinstructionnode3 isa nullable AInstruction
+ var teolnode5 = nodearraylist3
+ assert teolnode5 isa nullable TEol
+ var plinenode1: nullable AInstructionLine = new AInstructionLine.init_ainstructionline(
+ plabeldeclnode2,
+ pinstructionnode3,
+ null,
+ teolnode5
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction10
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var pinstructionnode3 = nodearraylist1
+ assert pinstructionnode3 isa nullable AInstruction
+ var tcommentnode4 = nodearraylist2
+ assert tcommentnode4 isa nullable TComment
+ var teolnode5 = nodearraylist3
+ assert teolnode5 isa nullable TEol
+ var plinenode1: nullable AInstructionLine = new AInstructionLine.init_ainstructionline(
+ null,
+ pinstructionnode3,
+ tcommentnode4,
+ teolnode5
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction11
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist4 = p.pop
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var plabeldeclnode2 = nodearraylist1
+ assert plabeldeclnode2 isa nullable ALabelDecl
+ var pinstructionnode3 = nodearraylist2
+ assert pinstructionnode3 isa nullable AInstruction
+ var tcommentnode4 = nodearraylist3
+ assert tcommentnode4 isa nullable TComment
+ var teolnode5 = nodearraylist4
+ assert teolnode5 isa nullable TEol
+ var plinenode1: nullable AInstructionLine = new AInstructionLine.init_ainstructionline(
+ plabeldeclnode2,
+ pinstructionnode3,
+ tcommentnode4,
+ teolnode5
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction12
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var pdirectivenode3 = nodearraylist1
+ assert pdirectivenode3 isa nullable ADirective
+ var teolnode5 = nodearraylist2
+ assert teolnode5 isa nullable TEol
+ var plinenode1: nullable ADirectiveLine = new ADirectiveLine.init_adirectiveline(
+ null,
+ pdirectivenode3,
+ null,
+ teolnode5
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction13
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var plabeldeclnode2 = nodearraylist1
+ assert plabeldeclnode2 isa nullable ALabelDecl
+ var pdirectivenode3 = nodearraylist2
+ assert pdirectivenode3 isa nullable ADirective
+ var teolnode5 = nodearraylist3
+ assert teolnode5 isa nullable TEol
+ var plinenode1: nullable ADirectiveLine = new ADirectiveLine.init_adirectiveline(
+ plabeldeclnode2,
+ pdirectivenode3,
+ null,
+ teolnode5
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction14
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var pdirectivenode3 = nodearraylist1
+ assert pdirectivenode3 isa nullable ADirective
+ var tcommentnode4 = nodearraylist2
+ assert tcommentnode4 isa nullable TComment
+ var teolnode5 = nodearraylist3
+ assert teolnode5 isa nullable TEol
+ var plinenode1: nullable ADirectiveLine = new ADirectiveLine.init_adirectiveline(
+ null,
+ pdirectivenode3,
+ tcommentnode4,
+ teolnode5
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction15
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist4 = p.pop
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var plabeldeclnode2 = nodearraylist1
+ assert plabeldeclnode2 isa nullable ALabelDecl
+ var pdirectivenode3 = nodearraylist2
+ assert pdirectivenode3 isa nullable ADirective
+ var tcommentnode4 = nodearraylist3
+ assert tcommentnode4 isa nullable TComment
+ var teolnode5 = nodearraylist4
+ assert teolnode5 isa nullable TEol
+ var plinenode1: nullable ADirectiveLine = new ADirectiveLine.init_adirectiveline(
+ plabeldeclnode2,
+ pdirectivenode3,
+ tcommentnode4,
+ teolnode5
+ )
+ node_list = plinenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction16
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var tidnode2 = nodearraylist1
+ assert tidnode2 isa nullable TId
+ var tcolonnode3 = nodearraylist2
+ assert tcolonnode3 isa nullable TColon
+ var plabeldeclnode1: nullable ALabelDecl = new ALabelDecl.init_alabeldecl(
+ tidnode2,
+ tcolonnode3
+ )
+ node_list = plabeldeclnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction17
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var tidnode2 = nodearraylist1
+ assert tidnode2 isa nullable TId
+ var pinstructionnode1: nullable AUnaryInstruction = new AUnaryInstruction.init_aunaryinstruction(
+ tidnode2
+ )
+ node_list = pinstructionnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction18
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var tidnode2 = nodearraylist1
+ assert tidnode2 isa nullable TId
+ var poperandnode3 = nodearraylist2
+ assert poperandnode3 isa nullable AOperand
+ var pinstructionnode1: nullable ABinaryInstruction = new ABinaryInstruction.init_abinaryinstruction(
+ tidnode2,
+ poperandnode3
+ )
+ node_list = pinstructionnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction19
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var pvaluenode2 = nodearraylist1
+ assert pvaluenode2 isa nullable AValue
+ var poperandnode1: nullable AImmediateOperand = new AImmediateOperand.init_aimmediateoperand(
+ pvaluenode2
+ )
+ node_list = poperandnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction20
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist3 = p.pop
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var pvaluenode2 = nodearraylist1
+ assert pvaluenode2 isa nullable AValue
+ var tcommanode3 = nodearraylist2
+ assert tcommanode3 isa nullable TComma
+ var tidnode4 = nodearraylist3
+ assert tidnode4 isa nullable TId
+ var poperandnode1: nullable AAnyOperand = new AAnyOperand.init_aanyoperand(
+ pvaluenode2,
+ tcommanode3,
+ tidnode4
+ )
+ node_list = poperandnode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction21
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var tidnode2 = nodearraylist1
+ assert tidnode2 isa nullable TId
+ var pvaluenode1: nullable ALabelValue = new ALabelValue.init_alabelvalue(
+ tidnode2
+ )
+ node_list = pvaluenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction22
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var tnumbernode2 = nodearraylist1
+ assert tnumbernode2 isa nullable TNumber
+ var pvaluenode1: nullable ANumberValue = new ANumberValue.init_anumbervalue(
+ tnumbernode2
+ )
+ node_list = pvaluenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction23
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var tcharnode2 = nodearraylist1
+ assert tcharnode2 isa nullable TChar
+ var pvaluenode1: nullable ACharValue = new ACharValue.init_acharvalue(
+ tcharnode2
+ )
+ node_list = pvaluenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction24
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var tstringnode2 = nodearraylist1
+ assert tstringnode2 isa nullable TString
+ var pvaluenode1: nullable AStringValue = new AStringValue.init_astringvalue(
+ tstringnode2
+ )
+ node_list = pvaluenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction25
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var thexnode2 = nodearraylist1
+ assert thexnode2 isa nullable THex
+ var pvaluenode1: nullable AHexValue = new AHexValue.init_ahexvalue(
+ thexnode2
+ )
+ node_list = pvaluenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction26
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var ttkbytenode2 = nodearraylist1
+ assert ttkbytenode2 isa nullable TTkByte
+ var pvaluenode3 = nodearraylist2
+ assert pvaluenode3 isa nullable AValue
+ var pdirectivenode1: nullable AByteDirective = new AByteDirective.init_abytedirective(
+ ttkbytenode2,
+ pvaluenode3
+ )
+ node_list = pdirectivenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction27
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var ttkwordnode2 = nodearraylist1
+ assert ttkwordnode2 isa nullable TTkWord
+ var pvaluenode3 = nodearraylist2
+ assert pvaluenode3 isa nullable AValue
+ var pdirectivenode1: nullable AWordDirective = new AWordDirective.init_aworddirective(
+ ttkwordnode2,
+ pvaluenode3
+ )
+ node_list = pdirectivenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction28
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var ttkblocknode2 = nodearraylist1
+ assert ttkblocknode2 isa nullable TTkBlock
+ var pvaluenode3 = nodearraylist2
+ assert pvaluenode3 isa nullable AValue
+ var pdirectivenode1: nullable ABlockDirective = new ABlockDirective.init_ablockdirective(
+ ttkblocknode2,
+ pvaluenode3
+ )
+ node_list = pdirectivenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction29
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var ttkasciinode2 = nodearraylist1
+ assert ttkasciinode2 isa nullable TTkAscii
+ var pvaluenode3 = nodearraylist2
+ assert pvaluenode3 isa nullable AValue
+ var pdirectivenode1: nullable AAsciiDirective = new AAsciiDirective.init_aasciidirective(
+ ttkasciinode2,
+ pvaluenode3
+ )
+ node_list = pdirectivenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction30
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var ttkaddrssnode2 = nodearraylist1
+ assert ttkaddrssnode2 isa nullable TTkAddrss
+ var pvaluenode3 = nodearraylist2
+ assert pvaluenode3 isa nullable AValue
+ var pdirectivenode1: nullable AAddrssDirective = new AAddrssDirective.init_aaddrssdirective(
+ ttkaddrssnode2,
+ pvaluenode3
+ )
+ node_list = pdirectivenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction31
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var ttkequatenode2 = nodearraylist1
+ assert ttkequatenode2 isa nullable TTkEquate
+ var pvaluenode3 = nodearraylist2
+ assert pvaluenode3 isa nullable AValue
+ var pdirectivenode1: nullable AEquateDirective = new AEquateDirective.init_aequatedirective(
+ ttkequatenode2,
+ pvaluenode3
+ )
+ node_list = pdirectivenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction32
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var ttkburnnode2 = nodearraylist1
+ assert ttkburnnode2 isa nullable TTkBurn
+ var pvaluenode3 = nodearraylist2
+ assert pvaluenode3 isa nullable AValue
+ var pdirectivenode1: nullable ABurnDirective = new ABurnDirective.init_aburndirective(
+ ttkburnnode2,
+ pvaluenode3
+ )
+ node_list = pdirectivenode1
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction33
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist1 = p.pop
+ var listnode2 = new Array[Object]
+ var plinenode1 = nodearraylist1
+ if plinenode1 != null then
+ listnode2.add(plinenode1)
+ end
+ node_list = listnode2
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+private class ReduceAction34
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+ var nodearraylist2 = p.pop
+ var nodearraylist1 = p.pop
+ var listnode3 = new Array[Object]
+ var listnode1 = nodearraylist1
+ assert listnode1 isa Array[Object]
+ var plinenode2 = nodearraylist2
+ listnode3 = concat(listnode3, listnode1)
+ if plinenode2 != null then
+ listnode3.add(plinenode2)
+ end
+ node_list = listnode3
+ p.push(p.go_to(_goto), node_list)
+ end
+end
--- /dev/null
+# Raw AST node hierarchy.
+# This file was generated by SableCC (http://www.sablecc.org/).
+package parser_abs
+
+import location
+
+# Root of the AST hierarchy
+abstract class ANode
+ var _location: nullable Location
+
+ # Location is set during AST building. Once built, location cannon be null
+ # However, manual instanciated nodes may need mode care
+ fun location: Location do return _location.as(not null)
+end
+
+# Ancestor of all tokens
+abstract class Token
+ super ANode
+end
+
+# Ancestor of all productions
+abstract class Prod
+ super ANode
+ fun location=(loc: Location) do _location = loc
+end
+class TEol
+ super Token
+end
+class TNumber
+ super Token
+end
+class TFloat
+ super Token
+end
+class TChar
+ super Token
+end
+class TString
+ super Token
+end
+class THex
+ super Token
+end
+class TColon
+ super Token
+end
+class TComma
+ super Token
+end
+class TComment
+ super Token
+end
+class TTkByte
+ super Token
+end
+class TTkWord
+ super Token
+end
+class TTkBlock
+ super Token
+end
+class TTkAscii
+ super Token
+end
+class TTkAddrss
+ super Token
+end
+class TTkEquate
+ super Token
+end
+class TTkBurn
+ super Token
+end
+class TEndBlock
+ super Token
+end
+class TId
+ super Token
+end
+class EOF
+ super Token
+private init noinit do end
+end
+class AError
+ super EOF
+private init noinit do end
+end
+
+class AListing super Prod end
+class ALine super Prod end
+class ALabelDecl super Prod end
+class AInstruction super Prod end
+class AOperand super Prod end
+class AValue super Prod end
+class ADirective super Prod end
+
+class AListing
+ super AListing
+ readable var _n_lines: List[ALine] = new List[ALine]
+ readable var _n_label_decl: nullable ALabelDecl = null
+ readable var _n_end_block: TEndBlock
+end
+class AEmptyLine
+ super ALine
+ readable var _n_label_decl: nullable ALabelDecl = null
+ readable var _n_comment: nullable TComment = null
+ readable var _n_eol: TEol
+end
+class AInstructionLine
+ super ALine
+ readable var _n_label_decl: nullable ALabelDecl = null
+ readable var _n_instruction: AInstruction
+ readable var _n_comment: nullable TComment = null
+ readable var _n_eol: TEol
+end
+class ADirectiveLine
+ super ALine
+ readable var _n_label_decl: nullable ALabelDecl = null
+ readable var _n_directive: ADirective
+ readable var _n_comment: nullable TComment = null
+ readable var _n_eol: TEol
+end
+class ALabelDecl
+ super ALabelDecl
+ readable var _n_id: TId
+ readable var _n_colon: TColon
+end
+class AUnaryInstruction
+ super AInstruction
+ readable var _n_id: TId
+end
+class ABinaryInstruction
+ super AInstruction
+ readable var _n_id: TId
+ readable var _n_operand: AOperand
+end
+class AImmediateOperand
+ super AOperand
+ readable var _n_value: AValue
+end
+class AAnyOperand
+ super AOperand
+ readable var _n_value: AValue
+ readable var _n_comma: TComma
+ readable var _n_id: TId
+end
+class ALabelValue
+ super AValue
+ readable var _n_id: TId
+end
+class ANumberValue
+ super AValue
+ readable var _n_number: TNumber
+end
+class ACharValue
+ super AValue
+ readable var _n_char: TChar
+end
+class AStringValue
+ super AValue
+ readable var _n_string: TString
+end
+class AHexValue
+ super AValue
+ readable var _n_hex: THex
+end
+class AByteDirective
+ super ADirective
+ readable var _n_tk_byte: TTkByte
+ readable var _n_value: AValue
+end
+class AWordDirective
+ super ADirective
+ readable var _n_tk_word: TTkWord
+ readable var _n_value: AValue
+end
+class ABlockDirective
+ super ADirective
+ readable var _n_tk_block: TTkBlock
+ readable var _n_value: AValue
+end
+class AAsciiDirective
+ super ADirective
+ readable var _n_tk_ascii: TTkAscii
+ readable var _n_value: AValue
+end
+class AAddrssDirective
+ super ADirective
+ readable var _n_tk_addrss: TTkAddrss
+ readable var _n_value: AValue
+end
+class AEquateDirective
+ super ADirective
+ readable var _n_tk_equate: TTkEquate
+ readable var _n_value: AValue
+end
+class ABurnDirective
+ super ADirective
+ readable var _n_tk_burn: TTkBurn
+ readable var _n_value: AValue
+end
+
+class Start
+ super Prod
+ readable var _n_base: nullable AListing
+ readable var _n_eof: EOF
+ init(
+ n_base: nullable AListing,
+ n_eof: EOF)
+ do
+ _n_base = n_base
+ _n_eof = n_eof
+ end
+
+end
--- /dev/null
+# Raw AST node hierarchy.
+# This file was generated by SableCC (http://www.sablecc.org/).
+module parser_nodes
+
+import location
+
+# Root of the AST hierarchy
+abstract class ANode
+ var _location: nullable Location
+
+ # Location is set during AST building. Once built, location cannon be null
+ # However, manual instanciated nodes may need mode care
+ fun location: Location do return _location.as(not null)
+end
+
+# Ancestor of all tokens
+abstract class Token
+ super ANode
+
+ fun text : String is abstract
+end
+
+# Ancestor of all productions
+abstract class Prod
+ super ANode
+ fun location=(loc: Location) do _location = loc
+end
+class TEol
+ super Token
+end
+class TNumber
+ super Token
+end
+class TFloat
+ super Token
+end
+class TChar
+ super Token
+end
+class TString
+ super Token
+end
+class THex
+ super Token
+end
+class TColon
+ super Token
+end
+class TComma
+ super Token
+end
+class TComment
+ super Token
+end
+class TTkByte
+ super Token
+end
+class TTkWord
+ super Token
+end
+class TTkBlock
+ super Token
+end
+class TTkAscii
+ super Token
+end
+class TTkAddrss
+ super Token
+end
+class TTkEquate
+ super Token
+end
+class TTkBurn
+ super Token
+end
+class TEndBlock
+ super Token
+end
+class TId
+ super Token
+end
+class EOF
+ super Token
+ #private init noinit do end
+end
+class AError
+ super EOF
+ #private init noinit do end
+end
+
+class ALine
+ super Prod
+ readable var _n_label_decl: nullable ALabelDecl = null
+ readable var _n_comment: nullable TComment = null
+end
+class AInstruction
+ super Prod
+ readable writable var _n_id: TId
+end
+class AOperand
+ super Prod
+ readable var _n_value: AValue
+end
+class AValue super Prod end
+class ADirective super Prod end
+
+class AListing
+ super Prod
+ readable var _n_lines: List[ALine] = new List[ALine]
+ readable var _n_label_decl: nullable ALabelDecl = null
+ readable var _n_end_block: TEndBlock
+end
+class AEmptyLine
+ super ALine
+ readable var _n_eol: TEol
+end
+abstract class ANonEmptyLine
+ super ALine
+end
+class AInstructionLine
+ super ANonEmptyLine
+ readable var _n_instruction: AInstruction
+ readable var _n_eol: TEol
+end
+class ADirectiveLine
+ super ANonEmptyLine
+ readable var _n_directive: ADirective
+ readable var _n_eol: TEol
+end
+class ALabelDecl
+ super Prod
+ readable var _n_id: TId
+ readable var _n_colon: TColon
+end
+class AUnaryInstruction
+ super AInstruction
+end
+class ABinaryInstruction
+ super AInstruction
+ readable var _n_operand: AOperand
+end
+class AImmediateOperand
+ super AOperand
+end
+class AAnyOperand
+ super AOperand
+ readable var _n_comma: TComma
+ readable var _n_id: TId
+end
+class ALabelValue
+ super AValue
+ readable var _n_id: TId
+end
+class ANumberValue
+ super AValue
+ readable var _n_number: TNumber
+end
+class ACharValue
+ super AValue
+ readable var _n_char: TChar
+end
+class AStringValue
+ super AValue
+ readable var _n_string: TString
+end
+class AHexValue
+ super AValue
+ readable var _n_hex: THex
+end
+class AByteDirective
+ super ADirective
+ readable var _n_tk_byte: TTkByte
+ readable var _n_value: AValue
+end
+class AWordDirective
+ super ADirective
+ readable var _n_tk_word: TTkWord
+ readable var _n_value: AValue
+end
+class ABlockDirective
+ super ADirective
+ readable var _n_tk_block: TTkBlock
+ readable var _n_value: AValue
+end
+class AAsciiDirective
+ super ADirective
+ readable var _n_tk_ascii: TTkAscii
+ readable var _n_value: AValue
+end
+class AAddrssDirective
+ super ADirective
+ readable var _n_tk_addrss: TTkAddrss
+ readable var _n_value: AValue
+end
+class AEquateDirective
+ super ADirective
+ readable var _n_tk_equate: TTkEquate
+ readable var _n_value: AValue
+end
+class ABurnDirective
+ super ADirective
+ readable var _n_tk_burn: TTkBurn
+ readable var _n_value: AValue
+end
+
+class Start
+ super Prod
+ readable var _n_base: nullable AListing
+ readable var _n_eof: EOF
+ init(n_base: nullable AListing, n_eof: EOF)
+ do
+ super(null)
+ _n_base = n_base
+ _n_eof = n_eof
+ end
+end
--- /dev/null
+# Production AST nodes full definition.
+# This file was generated by SableCC (http://www.sablecc.org/).
+module parser_prod
+
+import lexer
+intrude import parser_nodes
+private import tables
+
+redef class ANode
+ # Parent of the node in the AST
+ readable writable var _parent: nullable ANode
+
+ # Remove a child from the AST
+ fun remove_child(child: ANode)
+ do
+ replace_child(child, null)
+ end
+
+ # Replace a child with an other node in the AST
+ fun replace_child(old_child: ANode, new_child: nullable ANode) is abstract
+
+ # Replace itself with an other node in the AST
+ fun replace_with(node: ANode)
+ do
+ if _parent != null then
+ _parent.replace_child(self, node)
+ end
+ end
+
+ # Visit all nodes in order.
+ # Thus, call "v.visit(e)" for each node e
+ fun visit_all(v: Visitor) is abstract
+end
+
+redef class Token
+ redef fun visit_all(v: Visitor) do end
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode) do end
+end
+
+redef class Prod
+ redef fun replace_with(n: ANode)
+ do
+ super
+ assert n isa Prod
+ n.location = location
+ end
+end
+
+# Abstract standard visitor
+abstract class Visitor
+ # What the visitor do when a node is visited
+ # Concrete visitors should redefine this method.
+ protected fun visit(e: nullable ANode) is abstract
+
+ # Ask the visitor to visit a given node.
+ # Usually automatically called by visit_all* methods.
+ # This methos should not be redefined
+ fun enter_visit(e: nullable ANode)
+ do
+ var old = _current_node
+ _current_node = e
+ visit(e)
+ _current_node = old
+ end
+
+ # The current visited node
+ readable var _current_node: nullable ANode = null
+end
+
+redef class AListing
+ private init empty_init do end
+
+ init init_alisting (
+ n_lines: Collection[Object], # Should be Collection[ALine]
+ n_label_decl: nullable ALabelDecl,
+ n_end_block: nullable TEndBlock
+ )
+ do
+ empty_init
+ for n in n_lines do
+ assert n isa ALine
+ _n_lines.add(n)
+ n.parent = self
+ end
+ _n_label_decl = n_label_decl
+ if n_label_decl != null then
+ n_label_decl.parent = self
+ end
+ _n_end_block = n_end_block.as(not null)
+ n_end_block.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ for i in [0.._n_lines.length[ do
+ if _n_lines[i] == old_child then
+ if new_child != null then
+ assert new_child isa ALine
+ _n_lines[i] = new_child
+ new_child.parent = self
+ else
+ _n_lines.remove_at(i)
+ end
+ return
+ end
+ end
+ if _n_label_decl == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa ALabelDecl
+ _n_label_decl = new_child
+ else
+ _n_label_decl = null
+ end
+ return
+ end
+ if _n_end_block == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TEndBlock
+ _n_end_block = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ for n in _n_lines do
+ v.enter_visit(n)
+ end
+ if _n_label_decl != null then
+ v.enter_visit(_n_label_decl.as(not null))
+ end
+ v.enter_visit(_n_end_block)
+ end
+end
+redef class AEmptyLine
+ private init empty_init do end
+
+ init init_aemptyline (
+ n_label_decl: nullable ALabelDecl,
+ n_comment: nullable TComment,
+ n_eol: nullable TEol
+ )
+ do
+ empty_init
+ _n_label_decl = n_label_decl
+ if n_label_decl != null then
+ n_label_decl.parent = self
+ end
+ _n_comment = n_comment
+ if n_comment != null then
+ n_comment.parent = self
+ end
+ _n_eol = n_eol.as(not null)
+ n_eol.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_label_decl == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa ALabelDecl
+ _n_label_decl = new_child
+ else
+ _n_label_decl = null
+ end
+ return
+ end
+ if _n_comment == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TComment
+ _n_comment = new_child
+ else
+ _n_comment = null
+ end
+ return
+ end
+ if _n_eol == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TEol
+ _n_eol = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ if _n_label_decl != null then
+ v.enter_visit(_n_label_decl.as(not null))
+ end
+ if _n_comment != null then
+ v.enter_visit(_n_comment.as(not null))
+ end
+ v.enter_visit(_n_eol)
+ end
+end
+redef class AInstructionLine
+ private init empty_init do end
+
+ init init_ainstructionline (
+ n_label_decl: nullable ALabelDecl,
+ n_instruction: nullable AInstruction,
+ n_comment: nullable TComment,
+ n_eol: nullable TEol
+ )
+ do
+ empty_init
+ _n_label_decl = n_label_decl
+ if n_label_decl != null then
+ n_label_decl.parent = self
+ end
+ _n_instruction = n_instruction.as(not null)
+ n_instruction.parent = self
+ _n_comment = n_comment
+ if n_comment != null then
+ n_comment.parent = self
+ end
+ _n_eol = n_eol.as(not null)
+ n_eol.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_label_decl == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa ALabelDecl
+ _n_label_decl = new_child
+ else
+ _n_label_decl = null
+ end
+ return
+ end
+ if _n_instruction == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AInstruction
+ _n_instruction = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_comment == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TComment
+ _n_comment = new_child
+ else
+ _n_comment = null
+ end
+ return
+ end
+ if _n_eol == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TEol
+ _n_eol = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ if _n_label_decl != null then
+ v.enter_visit(_n_label_decl.as(not null))
+ end
+ v.enter_visit(_n_instruction)
+ if _n_comment != null then
+ v.enter_visit(_n_comment.as(not null))
+ end
+ v.enter_visit(_n_eol)
+ end
+end
+redef class ADirectiveLine
+ private init empty_init do end
+
+ init init_adirectiveline (
+ n_label_decl: nullable ALabelDecl,
+ n_directive: nullable ADirective,
+ n_comment: nullable TComment,
+ n_eol: nullable TEol
+ )
+ do
+ empty_init
+ _n_label_decl = n_label_decl
+ if n_label_decl != null then
+ n_label_decl.parent = self
+ end
+ _n_directive = n_directive.as(not null)
+ n_directive.parent = self
+ _n_comment = n_comment
+ if n_comment != null then
+ n_comment.parent = self
+ end
+ _n_eol = n_eol.as(not null)
+ n_eol.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_label_decl == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa ALabelDecl
+ _n_label_decl = new_child
+ else
+ _n_label_decl = null
+ end
+ return
+ end
+ if _n_directive == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa ADirective
+ _n_directive = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_comment == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TComment
+ _n_comment = new_child
+ else
+ _n_comment = null
+ end
+ return
+ end
+ if _n_eol == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TEol
+ _n_eol = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ if _n_label_decl != null then
+ v.enter_visit(_n_label_decl.as(not null))
+ end
+ v.enter_visit(_n_directive)
+ if _n_comment != null then
+ v.enter_visit(_n_comment.as(not null))
+ end
+ v.enter_visit(_n_eol)
+ end
+end
+redef class ALabelDecl
+ private init empty_init do end
+
+ init init_alabeldecl (
+ n_id: nullable TId,
+ n_colon: nullable TColon
+ )
+ do
+ empty_init
+ _n_id = n_id.as(not null)
+ n_id.parent = self
+ _n_colon = n_colon.as(not null)
+ n_colon.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_id == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TId
+ _n_id = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_colon == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TColon
+ _n_colon = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_id)
+ v.enter_visit(_n_colon)
+ end
+end
+redef class AUnaryInstruction
+ private init empty_init do end
+
+ init init_aunaryinstruction (
+ n_id: nullable TId
+ )
+ do
+ empty_init
+ _n_id = n_id.as(not null)
+ n_id.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_id == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TId
+ _n_id = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_id)
+ end
+end
+redef class ABinaryInstruction
+ private init empty_init do end
+
+ init init_abinaryinstruction (
+ n_id: nullable TId,
+ n_operand: nullable AOperand
+ )
+ do
+ empty_init
+ _n_id = n_id.as(not null)
+ n_id.parent = self
+ _n_operand = n_operand.as(not null)
+ n_operand.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_id == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TId
+ _n_id = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_operand == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AOperand
+ _n_operand = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_id)
+ v.enter_visit(_n_operand)
+ end
+end
+redef class AImmediateOperand
+ private init empty_init do end
+
+ init init_aimmediateoperand (
+ n_value: nullable AValue
+ )
+ do
+ empty_init
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_value)
+ end
+end
+redef class AAnyOperand
+ private init empty_init do end
+
+ init init_aanyoperand (
+ n_value: nullable AValue,
+ n_comma: nullable TComma,
+ n_id: nullable TId
+ )
+ do
+ empty_init
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ _n_comma = n_comma.as(not null)
+ n_comma.parent = self
+ _n_id = n_id.as(not null)
+ n_id.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_comma == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TComma
+ _n_comma = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_id == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TId
+ _n_id = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_value)
+ v.enter_visit(_n_comma)
+ v.enter_visit(_n_id)
+ end
+end
+redef class ALabelValue
+ private init empty_init do end
+
+ init init_alabelvalue (
+ n_id: nullable TId
+ )
+ do
+ empty_init
+ _n_id = n_id.as(not null)
+ n_id.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_id == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TId
+ _n_id = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_id)
+ end
+end
+redef class ANumberValue
+ private init empty_init do end
+
+ init init_anumbervalue (
+ n_number: nullable TNumber
+ )
+ do
+ empty_init
+ _n_number = n_number.as(not null)
+ n_number.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_number == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TNumber
+ _n_number = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_number)
+ end
+end
+redef class ACharValue
+ private init empty_init do end
+
+ init init_acharvalue (
+ n_char: nullable TChar
+ )
+ do
+ empty_init
+ _n_char = n_char.as(not null)
+ n_char.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_char == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TChar
+ _n_char = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_char)
+ end
+end
+redef class AStringValue
+ private init empty_init do end
+
+ init init_astringvalue (
+ n_string: nullable TString
+ )
+ do
+ empty_init
+ _n_string = n_string.as(not null)
+ n_string.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_string == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TString
+ _n_string = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_string)
+ end
+end
+redef class AHexValue
+ private init empty_init do end
+
+ init init_ahexvalue (
+ n_hex: nullable THex
+ )
+ do
+ empty_init
+ _n_hex = n_hex.as(not null)
+ n_hex.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_hex == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa THex
+ _n_hex = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_hex)
+ end
+end
+redef class AByteDirective
+ private init empty_init do end
+
+ init init_abytedirective (
+ n_tk_byte: nullable TTkByte,
+ n_value: nullable AValue
+ )
+ do
+ empty_init
+ _n_tk_byte = n_tk_byte.as(not null)
+ n_tk_byte.parent = self
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_tk_byte == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TTkByte
+ _n_tk_byte = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_tk_byte)
+ v.enter_visit(_n_value)
+ end
+end
+redef class AWordDirective
+ private init empty_init do end
+
+ init init_aworddirective (
+ n_tk_word: nullable TTkWord,
+ n_value: nullable AValue
+ )
+ do
+ empty_init
+ _n_tk_word = n_tk_word.as(not null)
+ n_tk_word.parent = self
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_tk_word == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TTkWord
+ _n_tk_word = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_tk_word)
+ v.enter_visit(_n_value)
+ end
+end
+redef class ABlockDirective
+ private init empty_init do end
+
+ init init_ablockdirective (
+ n_tk_block: nullable TTkBlock,
+ n_value: nullable AValue
+ )
+ do
+ empty_init
+ _n_tk_block = n_tk_block.as(not null)
+ n_tk_block.parent = self
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_tk_block == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TTkBlock
+ _n_tk_block = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_tk_block)
+ v.enter_visit(_n_value)
+ end
+end
+redef class AAsciiDirective
+ private init empty_init do end
+
+ init init_aasciidirective (
+ n_tk_ascii: nullable TTkAscii,
+ n_value: nullable AValue
+ )
+ do
+ empty_init
+ _n_tk_ascii = n_tk_ascii.as(not null)
+ n_tk_ascii.parent = self
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_tk_ascii == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TTkAscii
+ _n_tk_ascii = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_tk_ascii)
+ v.enter_visit(_n_value)
+ end
+end
+redef class AAddrssDirective
+ private init empty_init do end
+
+ init init_aaddrssdirective (
+ n_tk_addrss: nullable TTkAddrss,
+ n_value: nullable AValue
+ )
+ do
+ empty_init
+ _n_tk_addrss = n_tk_addrss.as(not null)
+ n_tk_addrss.parent = self
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_tk_addrss == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TTkAddrss
+ _n_tk_addrss = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_tk_addrss)
+ v.enter_visit(_n_value)
+ end
+end
+redef class AEquateDirective
+ private init empty_init do end
+
+ init init_aequatedirective (
+ n_tk_equate: nullable TTkEquate,
+ n_value: nullable AValue
+ )
+ do
+ empty_init
+ _n_tk_equate = n_tk_equate.as(not null)
+ n_tk_equate.parent = self
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_tk_equate == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TTkEquate
+ _n_tk_equate = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_tk_equate)
+ v.enter_visit(_n_value)
+ end
+end
+redef class ABurnDirective
+ private init empty_init do end
+
+ init init_aburndirective (
+ n_tk_burn: nullable TTkBurn,
+ n_value: nullable AValue
+ )
+ do
+ empty_init
+ _n_tk_burn = n_tk_burn.as(not null)
+ n_tk_burn.parent = self
+ _n_value = n_value.as(not null)
+ n_value.parent = self
+ end
+
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_tk_burn == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa TTkBurn
+ _n_tk_burn = new_child
+ else
+ abort
+ end
+ return
+ end
+ if _n_value == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa AValue
+ _n_value = new_child
+ else
+ abort
+ end
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ v.enter_visit(_n_tk_burn)
+ v.enter_visit(_n_value)
+ end
+end
+
+redef class Start
+ redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+ do
+ if _n_base == old_child then
+ if new_child == null then
+ else
+ new_child.parent = self
+ assert new_child isa AListing
+ _n_base = new_child
+ end
+ old_child.parent = null
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ if _n_base != null then
+ v.enter_visit(_n_base.as(not null))
+ end
+ v.enter_visit(_n_eof)
+ end
+end
--- /dev/null
+/*
+ * This file is part of the pep8analyser project.
+ *
+ * Copyright 2013 Alexis Laferriere <alexis.laf@xymus.net>
+ *
+ * Inspired from the Nit language grammar by:
+ * Copyright 2008-2009 Jean Privat <jean@pryen.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* This grammar defines the Pep/8 language. */
+Grammar pep8;
+
+/*****************************************************************************/
+Lexer
+/*****************************************************************************/
+
+all = ' ' .. '~';
+lowercase = 'a' .. 'z';
+uppercase = 'A' .. 'Z';
+digit = '0' .. '9';
+letter = lowercase | uppercase | digit | '_';
+
+tab = '\t';
+cr = '\n';
+lf = '\r';
+any = all - (cr | lf);
+
+str_char
+ = (any - '"') + '\\'
+ | '\\' any;
+
+eol_helper = cr lf | cr | lf; // This takes care of different platforms;
+
+hex_digit = '0' .. '9' | 'A' .. 'F' | 'a' .. 'f';
+
+blank = (' ' | tab)+;
+
+eol = eol_helper;
+
+number = '-'? digit+;
+hex = '0' ('x'|'X') hex_digit+;
+float = digit* '.' digit+;
+char = ('\'' ((any - '\'') - '\\') '\'')
+ | ('\'' '\\' any '\'')
+ | ('\'' '\\' 'x' hex_digit hex_digit '\'');
+string = '"' str_char* '"';
+
+colon = ':';
+comma = ',';
+comment = ';' any*;
+
+tk_byte = '.' ('B'|'b') ('Y'|'y') ('T'|'t') ('E'|'e');
+tk_word = '.' ('W'|'w') ('O'|'o') ('R'|'r') ('D'|'d');
+tk_block = '.' ('B'|'b') ('L'|'l') ('O'|'o') ('C'|'c') ('K'|'k');
+tk_ascii = '.' ('A'|'a') ('S'|'s') ('C'|'c') ('I'|'i') ('I'|'i');
+tk_addrss = '.' ('A'|'a') ('D'|'d') ('D'|'d') ('R'|'r') ('S'|'s') ('S'|'s');
+tk_equate = '.' ('E'|'e') ('Q'|'q') ('U'|'u') ('A'|'a') ('T'|'t') ('E'|'e');
+tk_burn = '.' ('B'|'b') ('U'|'u') ('R'|'r') ('N'|'n');
+
+end_block = '.' ('E'|'e') ('N'|'n') ('D'|'d') (any | eol_helper)*;
+
+id = (lowercase|uppercase|'_') letter*;
+
+/*****************************************************************************/
+Parser
+/*****************************************************************************/
+Ignored blank;
+listing = [lines]:line* label_decl? end_block;
+
+line
+ = {empty} label_decl? comment? eol
+ | {instruction} label_decl? instruction comment? eol
+ | {directive} label_decl? directive comment? eol;
+
+label_decl = id colon;
+
+instruction
+ = {unary} id
+ | {binary} id operand;
+
+/* operands
+ * We will manage which operands are possible with each stmt at a higher level.
+ * This will allow better error messages and a cleaner model. */
+operand
+ = {immediate} value
+ | {any} value comma id;
+
+value
+ = {label} id
+ | {char} char
+ | {string} string;
+ /*| {hex} hex;*/
+directive
+ = {byte} tk_byte value
+ | {word} tk_word value
+ | {block} tk_block value
+ | {ascii} tk_ascii value
+ | {addrss} tk_addrss value
+ | {equate} tk_equate value
+ | {burn} tk_burn value;
+
--- /dev/null
+# Lexer generated by nitccimport nitcc_runtime
+import pep8_parser
+class MyLexer
+ super Lexer
+ redef fun start_state do return dfastate_0
+end
+redef class Object
+ private fun dfastate_0: DFAState0 do return once new DFAState0
+ private fun dfastate_1: DFAState1 do return once new DFAState1
+ private fun dfastate_2: DFAState2 do return once new DFAState2
+ private fun dfastate_3: DFAState3 do return once new DFAState3
+ private fun dfastate_4: DFAState4 do return once new DFAState4
+ private fun dfastate_5: DFAState5 do return once new DFAState5
+ private fun dfastate_6: DFAState6 do return once new DFAState6
+ private fun dfastate_7: DFAState7 do return once new DFAState7
+ private fun dfastate_8: DFAState8 do return once new DFAState8
+ private fun dfastate_9: DFAState9 do return once new DFAState9
+ private fun dfastate_10: DFAState10 do return once new DFAState10
+ private fun dfastate_11: DFAState11 do return once new DFAState11
+ private fun dfastate_12: DFAState12 do return once new DFAState12
+ private fun dfastate_13: DFAState13 do return once new DFAState13
+ private fun dfastate_14: DFAState14 do return once new DFAState14
+ private fun dfastate_15: DFAState15 do return once new DFAState15
+ private fun dfastate_16: DFAState16 do return once new DFAState16
+ private fun dfastate_17: DFAState17 do return once new DFAState17
+ private fun dfastate_18: DFAState18 do return once new DFAState18
+ private fun dfastate_19: DFAState19 do return once new DFAState19
+ private fun dfastate_20: DFAState20 do return once new DFAState20
+ private fun dfastate_21: DFAState21 do return once new DFAState21
+ private fun dfastate_22: DFAState22 do return once new DFAState22
+ private fun dfastate_23: DFAState23 do return once new DFAState23
+ private fun dfastate_24: DFAState24 do return once new DFAState24
+ private fun dfastate_25: DFAState25 do return once new DFAState25
+ private fun dfastate_26: DFAState26 do return once new DFAState26
+ private fun dfastate_27: DFAState27 do return once new DFAState27
+ private fun dfastate_28: DFAState28 do return once new DFAState28
+ private fun dfastate_29: DFAState29 do return once new DFAState29
+ private fun dfastate_30: DFAState30 do return once new DFAState30
+ private fun dfastate_31: DFAState31 do return once new DFAState31
+ private fun dfastate_32: DFAState32 do return once new DFAState32
+ private fun dfastate_33: DFAState33 do return once new DFAState33
+ private fun dfastate_34: DFAState34 do return once new DFAState34
+ private fun dfastate_35: DFAState35 do return once new DFAState35
+ private fun dfastate_36: DFAState36 do return once new DFAState36
+ private fun dfastate_37: DFAState37 do return once new DFAState37
+ private fun dfastate_38: DFAState38 do return once new DFAState38
+ private fun dfastate_39: DFAState39 do return once new DFAState39
+ private fun dfastate_40: DFAState40 do return once new DFAState40
+ private fun dfastate_41: DFAState41 do return once new DFAState41
+ private fun dfastate_42: DFAState42 do return once new DFAState42
+ private fun dfastate_43: DFAState43 do return once new DFAState43
+ private fun dfastate_44: DFAState44 do return once new DFAState44
+ private fun dfastate_45: DFAState45 do return once new DFAState45
+ private fun dfastate_46: DFAState46 do return once new DFAState46
+ private fun dfastate_47: DFAState47 do return once new DFAState47
+ private fun dfastate_48: DFAState48 do return once new DFAState48
+ private fun dfastate_49: DFAState49 do return once new DFAState49
+ private fun dfastate_50: DFAState50 do return once new DFAState50
+ private fun dfastate_51: DFAState51 do return once new DFAState51
+ private fun dfastate_52: DFAState52 do return once new DFAState52
+ private fun dfastate_53: DFAState53 do return once new DFAState53
+ private fun dfastate_54: DFAState54 do return once new DFAState54
+ private fun dfastate_55: DFAState55 do return once new DFAState55
+ private fun dfastate_56: DFAState56 do return once new DFAState56
+ private fun dfastate_57: DFAState57 do return once new DFAState57
+ private fun dfastate_58: DFAState58 do return once new DFAState58
+ private fun dfastate_59: DFAState59 do return once new DFAState59
+ private fun dfastate_60: DFAState60 do return once new DFAState60
+ private fun dfastate_61: DFAState61 do return once new DFAState61
+ private fun dfastate_62: DFAState62 do return once new DFAState62
+ private fun dfastate_63: DFAState63 do return once new DFAState63
+ private fun dfastate_64: DFAState64 do return once new DFAState64
+ private fun dfastate_65: DFAState65 do return once new DFAState65
+ private fun dfastate_66: DFAState66 do return once new DFAState66
+ private fun dfastate_67: DFAState67 do return once new DFAState67
+ private fun dfastate_68: DFAState68 do return once new DFAState68
+ private fun dfastate_69: DFAState69 do return once new DFAState69
+ private fun dfastate_70: DFAState70 do return once new DFAState70
+ private fun dfastate_71: DFAState71 do return once new DFAState71
+ private fun dfastate_72: DFAState72 do return once new DFAState72
+ private fun dfastate_73: DFAState73 do return once new DFAState73
+ private fun dfastate_74: DFAState74 do return once new DFAState74
+ private fun dfastate_75: DFAState75 do return once new DFAState75
+ private fun dfastate_76: DFAState76 do return once new DFAState76
+ private fun dfastate_77: DFAState77 do return once new DFAState77
+ private fun dfastate_78: DFAState78 do return once new DFAState78
+ private fun dfastate_79: DFAState79 do return once new DFAState79
+ private fun dfastate_80: DFAState80 do return once new DFAState80
+ private fun dfastate_81: DFAState81 do return once new DFAState81
+ private fun dfastate_82: DFAState82 do return once new DFAState82
+ private fun dfastate_83: DFAState83 do return once new DFAState83
+ private fun dfastate_84: DFAState84 do return once new DFAState84
+ private fun dfastate_85: DFAState85 do return once new DFAState85
+ private fun dfastate_86: DFAState86 do return once new DFAState86
+ private fun dfastate_87: DFAState87 do return once new DFAState87
+ private fun dfastate_88: DFAState88 do return once new DFAState88
+ private fun dfastate_89: DFAState89 do return once new DFAState89
+ private fun dfastate_90: DFAState90 do return once new DFAState90
+ private fun dfastate_91: DFAState91 do return once new DFAState91
+ private fun dfastate_92: DFAState92 do return once new DFAState92
+ private fun dfastate_93: DFAState93 do return once new DFAState93
+ private fun dfastate_94: DFAState94 do return once new DFAState94
+ private fun dfastate_95: DFAState95 do return once new DFAState95
+ private fun dfastate_96: DFAState96 do return once new DFAState96
+ private fun dfastate_97: DFAState97 do return once new DFAState97
+ private fun dfastate_98: DFAState98 do return once new DFAState98
+ private fun dfastate_99: DFAState99 do return once new DFAState99
+ private fun dfastate_100: DFAState100 do return once new DFAState100
+ private fun dfastate_101: DFAState101 do return once new DFAState101
+ private fun dfastate_102: DFAState102 do return once new DFAState102
+ private fun dfastate_103: DFAState103 do return once new DFAState103
+ private fun dfastate_104: DFAState104 do return once new DFAState104
+ private fun dfastate_105: DFAState105 do return once new DFAState105
+ private fun dfastate_106: DFAState106 do return once new DFAState106
+ private fun dfastate_107: DFAState107 do return once new DFAState107
+ private fun dfastate_108: DFAState108 do return once new DFAState108
+ private fun dfastate_109: DFAState109 do return once new DFAState109
+ private fun dfastate_110: DFAState110 do return once new DFAState110
+ private fun dfastate_111: DFAState111 do return once new DFAState111
+ private fun dfastate_112: DFAState112 do return once new DFAState112
+end
+class MyNToken
+ super NToken
+end
+class DFAState0
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 46 then return dfastate_1
+ if c.ascii == 34 then return dfastate_2
+ if c.ascii == 39 then return dfastate_3
+ if c.ascii == 44 then return dfastate_4
+ if c.ascii == 58 then return dfastate_5
+ if c.ascii == 95 then return dfastate_6
+ if c.ascii == 97 then return dfastate_7
+ if c.ascii == 98 then return dfastate_7
+ if c.ascii == 99 then return dfastate_7
+ if c.ascii == 100 then return dfastate_7
+ if c.ascii == 101 then return dfastate_7
+ if c.ascii == 102 then return dfastate_7
+ if c.ascii == 103 then return dfastate_7
+ if c.ascii == 104 then return dfastate_7
+ if c.ascii == 105 then return dfastate_7
+ if c.ascii == 106 then return dfastate_7
+ if c.ascii == 107 then return dfastate_7
+ if c.ascii == 108 then return dfastate_7
+ if c.ascii == 109 then return dfastate_7
+ if c.ascii == 110 then return dfastate_7
+ if c.ascii == 111 then return dfastate_7
+ if c.ascii == 112 then return dfastate_7
+ if c.ascii == 113 then return dfastate_7
+ if c.ascii == 114 then return dfastate_7
+ if c.ascii == 115 then return dfastate_7
+ if c.ascii == 116 then return dfastate_7
+ if c.ascii == 117 then return dfastate_7
+ if c.ascii == 118 then return dfastate_7
+ if c.ascii == 119 then return dfastate_7
+ if c.ascii == 120 then return dfastate_7
+ if c.ascii == 121 then return dfastate_7
+ if c.ascii == 122 then return dfastate_7
+ if c.ascii == 65 then return dfastate_8
+ if c.ascii == 66 then return dfastate_8
+ if c.ascii == 67 then return dfastate_8
+ if c.ascii == 68 then return dfastate_8
+ if c.ascii == 69 then return dfastate_8
+ if c.ascii == 70 then return dfastate_8
+ if c.ascii == 71 then return dfastate_8
+ if c.ascii == 72 then return dfastate_8
+ if c.ascii == 73 then return dfastate_8
+ if c.ascii == 74 then return dfastate_8
+ if c.ascii == 75 then return dfastate_8
+ if c.ascii == 76 then return dfastate_8
+ if c.ascii == 77 then return dfastate_8
+ if c.ascii == 78 then return dfastate_8
+ if c.ascii == 79 then return dfastate_8
+ if c.ascii == 80 then return dfastate_8
+ if c.ascii == 81 then return dfastate_8
+ if c.ascii == 82 then return dfastate_8
+ if c.ascii == 83 then return dfastate_8
+ if c.ascii == 84 then return dfastate_8
+ if c.ascii == 85 then return dfastate_8
+ if c.ascii == 86 then return dfastate_8
+ if c.ascii == 87 then return dfastate_8
+ if c.ascii == 88 then return dfastate_8
+ if c.ascii == 89 then return dfastate_8
+ if c.ascii == 90 then return dfastate_8
+ if c.ascii == 13 then return dfastate_9
+ if c.ascii == 10 then return dfastate_10
+ if c.ascii == 59 then return dfastate_11
+ if c.ascii == 9 then return dfastate_12
+ if c.ascii == 32 then return dfastate_13
+ return null
+ end
+end
+class DFAState1
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 101 then return dfastate_43
+ if c.ascii == 69 then return dfastate_44
+ if c.ascii == 98 then return dfastate_45
+ if c.ascii == 66 then return dfastate_46
+ if c.ascii == 119 then return dfastate_47
+ if c.ascii == 87 then return dfastate_48
+ if c.ascii == 97 then return dfastate_49
+ if c.ascii == 65 then return dfastate_50
+ return null
+ end
+end
+class DFAState2
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_33
+ if c.ascii == 33 then return dfastate_33
+ if c.ascii == 35 then return dfastate_33
+ if c.ascii == 36 then return dfastate_33
+ if c.ascii == 37 then return dfastate_33
+ if c.ascii == 38 then return dfastate_33
+ if c.ascii == 39 then return dfastate_33
+ if c.ascii == 40 then return dfastate_33
+ if c.ascii == 41 then return dfastate_33
+ if c.ascii == 42 then return dfastate_33
+ if c.ascii == 43 then return dfastate_33
+ if c.ascii == 44 then return dfastate_33
+ if c.ascii == 45 then return dfastate_33
+ if c.ascii == 46 then return dfastate_33
+ if c.ascii == 47 then return dfastate_33
+ if c.ascii == 48 then return dfastate_33
+ if c.ascii == 49 then return dfastate_33
+ if c.ascii == 50 then return dfastate_33
+ if c.ascii == 51 then return dfastate_33
+ if c.ascii == 52 then return dfastate_33
+ if c.ascii == 53 then return dfastate_33
+ if c.ascii == 54 then return dfastate_33
+ if c.ascii == 55 then return dfastate_33
+ if c.ascii == 56 then return dfastate_33
+ if c.ascii == 57 then return dfastate_33
+ if c.ascii == 58 then return dfastate_33
+ if c.ascii == 59 then return dfastate_33
+ if c.ascii == 60 then return dfastate_33
+ if c.ascii == 61 then return dfastate_33
+ if c.ascii == 62 then return dfastate_33
+ if c.ascii == 63 then return dfastate_33
+ if c.ascii == 64 then return dfastate_33
+ if c.ascii == 65 then return dfastate_33
+ if c.ascii == 66 then return dfastate_33
+ if c.ascii == 67 then return dfastate_33
+ if c.ascii == 68 then return dfastate_33
+ if c.ascii == 69 then return dfastate_33
+ if c.ascii == 70 then return dfastate_33
+ if c.ascii == 71 then return dfastate_33
+ if c.ascii == 72 then return dfastate_33
+ if c.ascii == 73 then return dfastate_33
+ if c.ascii == 74 then return dfastate_33
+ if c.ascii == 75 then return dfastate_33
+ if c.ascii == 76 then return dfastate_33
+ if c.ascii == 77 then return dfastate_33
+ if c.ascii == 78 then return dfastate_33
+ if c.ascii == 79 then return dfastate_33
+ if c.ascii == 80 then return dfastate_33
+ if c.ascii == 81 then return dfastate_33
+ if c.ascii == 82 then return dfastate_33
+ if c.ascii == 83 then return dfastate_33
+ if c.ascii == 84 then return dfastate_33
+ if c.ascii == 85 then return dfastate_33
+ if c.ascii == 86 then return dfastate_33
+ if c.ascii == 87 then return dfastate_33
+ if c.ascii == 88 then return dfastate_33
+ if c.ascii == 89 then return dfastate_33
+ if c.ascii == 90 then return dfastate_33
+ if c.ascii == 91 then return dfastate_33
+ if c.ascii == 92 then return dfastate_34
+ if c.ascii == 93 then return dfastate_33
+ if c.ascii == 94 then return dfastate_33
+ if c.ascii == 95 then return dfastate_33
+ if c.ascii == 96 then return dfastate_33
+ if c.ascii == 97 then return dfastate_33
+ if c.ascii == 98 then return dfastate_33
+ if c.ascii == 99 then return dfastate_33
+ if c.ascii == 100 then return dfastate_33
+ if c.ascii == 101 then return dfastate_33
+ if c.ascii == 102 then return dfastate_33
+ if c.ascii == 103 then return dfastate_33
+ if c.ascii == 104 then return dfastate_33
+ if c.ascii == 105 then return dfastate_33
+ if c.ascii == 106 then return dfastate_33
+ if c.ascii == 107 then return dfastate_33
+ if c.ascii == 108 then return dfastate_33
+ if c.ascii == 109 then return dfastate_33
+ if c.ascii == 110 then return dfastate_33
+ if c.ascii == 111 then return dfastate_33
+ if c.ascii == 112 then return dfastate_33
+ if c.ascii == 113 then return dfastate_33
+ if c.ascii == 114 then return dfastate_33
+ if c.ascii == 115 then return dfastate_33
+ if c.ascii == 116 then return dfastate_33
+ if c.ascii == 117 then return dfastate_33
+ if c.ascii == 118 then return dfastate_33
+ if c.ascii == 119 then return dfastate_33
+ if c.ascii == 120 then return dfastate_33
+ if c.ascii == 121 then return dfastate_33
+ if c.ascii == 122 then return dfastate_33
+ if c.ascii == 123 then return dfastate_33
+ if c.ascii == 124 then return dfastate_33
+ if c.ascii == 125 then return dfastate_33
+ if c.ascii == 126 then return dfastate_33
+ if c.ascii == 34 then return dfastate_35
+ return null
+ end
+end
+class DFAState3
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_20
+ if c.ascii == 33 then return dfastate_20
+ if c.ascii == 34 then return dfastate_20
+ if c.ascii == 35 then return dfastate_20
+ if c.ascii == 36 then return dfastate_20
+ if c.ascii == 37 then return dfastate_20
+ if c.ascii == 38 then return dfastate_20
+ if c.ascii == 40 then return dfastate_20
+ if c.ascii == 41 then return dfastate_20
+ if c.ascii == 42 then return dfastate_20
+ if c.ascii == 43 then return dfastate_20
+ if c.ascii == 44 then return dfastate_20
+ if c.ascii == 45 then return dfastate_20
+ if c.ascii == 46 then return dfastate_20
+ if c.ascii == 47 then return dfastate_20
+ if c.ascii == 48 then return dfastate_20
+ if c.ascii == 49 then return dfastate_20
+ if c.ascii == 50 then return dfastate_20
+ if c.ascii == 51 then return dfastate_20
+ if c.ascii == 52 then return dfastate_20
+ if c.ascii == 53 then return dfastate_20
+ if c.ascii == 54 then return dfastate_20
+ if c.ascii == 55 then return dfastate_20
+ if c.ascii == 56 then return dfastate_20
+ if c.ascii == 57 then return dfastate_20
+ if c.ascii == 58 then return dfastate_20
+ if c.ascii == 59 then return dfastate_20
+ if c.ascii == 60 then return dfastate_20
+ if c.ascii == 61 then return dfastate_20
+ if c.ascii == 62 then return dfastate_20
+ if c.ascii == 63 then return dfastate_20
+ if c.ascii == 64 then return dfastate_20
+ if c.ascii == 65 then return dfastate_20
+ if c.ascii == 66 then return dfastate_20
+ if c.ascii == 67 then return dfastate_20
+ if c.ascii == 68 then return dfastate_20
+ if c.ascii == 69 then return dfastate_20
+ if c.ascii == 70 then return dfastate_20
+ if c.ascii == 71 then return dfastate_20
+ if c.ascii == 72 then return dfastate_20
+ if c.ascii == 73 then return dfastate_20
+ if c.ascii == 74 then return dfastate_20
+ if c.ascii == 75 then return dfastate_20
+ if c.ascii == 76 then return dfastate_20
+ if c.ascii == 77 then return dfastate_20
+ if c.ascii == 78 then return dfastate_20
+ if c.ascii == 79 then return dfastate_20
+ if c.ascii == 80 then return dfastate_20
+ if c.ascii == 81 then return dfastate_20
+ if c.ascii == 82 then return dfastate_20
+ if c.ascii == 83 then return dfastate_20
+ if c.ascii == 84 then return dfastate_20
+ if c.ascii == 85 then return dfastate_20
+ if c.ascii == 86 then return dfastate_20
+ if c.ascii == 87 then return dfastate_20
+ if c.ascii == 88 then return dfastate_20
+ if c.ascii == 89 then return dfastate_20
+ if c.ascii == 90 then return dfastate_20
+ if c.ascii == 91 then return dfastate_20
+ if c.ascii == 93 then return dfastate_20
+ if c.ascii == 94 then return dfastate_20
+ if c.ascii == 95 then return dfastate_20
+ if c.ascii == 96 then return dfastate_20
+ if c.ascii == 97 then return dfastate_20
+ if c.ascii == 98 then return dfastate_20
+ if c.ascii == 99 then return dfastate_20
+ if c.ascii == 100 then return dfastate_20
+ if c.ascii == 101 then return dfastate_20
+ if c.ascii == 102 then return dfastate_20
+ if c.ascii == 103 then return dfastate_20
+ if c.ascii == 104 then return dfastate_20
+ if c.ascii == 105 then return dfastate_20
+ if c.ascii == 106 then return dfastate_20
+ if c.ascii == 107 then return dfastate_20
+ if c.ascii == 108 then return dfastate_20
+ if c.ascii == 109 then return dfastate_20
+ if c.ascii == 110 then return dfastate_20
+ if c.ascii == 111 then return dfastate_20
+ if c.ascii == 112 then return dfastate_20
+ if c.ascii == 113 then return dfastate_20
+ if c.ascii == 114 then return dfastate_20
+ if c.ascii == 115 then return dfastate_20
+ if c.ascii == 116 then return dfastate_20
+ if c.ascii == 117 then return dfastate_20
+ if c.ascii == 118 then return dfastate_20
+ if c.ascii == 119 then return dfastate_20
+ if c.ascii == 120 then return dfastate_20
+ if c.ascii == 121 then return dfastate_20
+ if c.ascii == 122 then return dfastate_20
+ if c.ascii == 123 then return dfastate_20
+ if c.ascii == 124 then return dfastate_20
+ if c.ascii == 125 then return dfastate_20
+ if c.ascii == 126 then return dfastate_20
+ if c.ascii == 92 then return dfastate_21
+ return null
+ end
+end
+class DFAState4
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ncomma
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState5
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ncolon
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState6
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nid
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 95 then return dfastate_16
+ if c.ascii == 48 then return dfastate_17
+ if c.ascii == 49 then return dfastate_17
+ if c.ascii == 50 then return dfastate_17
+ if c.ascii == 51 then return dfastate_17
+ if c.ascii == 52 then return dfastate_17
+ if c.ascii == 53 then return dfastate_17
+ if c.ascii == 54 then return dfastate_17
+ if c.ascii == 55 then return dfastate_17
+ if c.ascii == 56 then return dfastate_17
+ if c.ascii == 57 then return dfastate_17
+ if c.ascii == 97 then return dfastate_18
+ if c.ascii == 98 then return dfastate_18
+ if c.ascii == 99 then return dfastate_18
+ if c.ascii == 100 then return dfastate_18
+ if c.ascii == 101 then return dfastate_18
+ if c.ascii == 102 then return dfastate_18
+ if c.ascii == 103 then return dfastate_18
+ if c.ascii == 104 then return dfastate_18
+ if c.ascii == 105 then return dfastate_18
+ if c.ascii == 106 then return dfastate_18
+ if c.ascii == 107 then return dfastate_18
+ if c.ascii == 108 then return dfastate_18
+ if c.ascii == 109 then return dfastate_18
+ if c.ascii == 110 then return dfastate_18
+ if c.ascii == 111 then return dfastate_18
+ if c.ascii == 112 then return dfastate_18
+ if c.ascii == 113 then return dfastate_18
+ if c.ascii == 114 then return dfastate_18
+ if c.ascii == 115 then return dfastate_18
+ if c.ascii == 116 then return dfastate_18
+ if c.ascii == 117 then return dfastate_18
+ if c.ascii == 118 then return dfastate_18
+ if c.ascii == 119 then return dfastate_18
+ if c.ascii == 120 then return dfastate_18
+ if c.ascii == 121 then return dfastate_18
+ if c.ascii == 122 then return dfastate_18
+ if c.ascii == 65 then return dfastate_19
+ if c.ascii == 66 then return dfastate_19
+ if c.ascii == 67 then return dfastate_19
+ if c.ascii == 68 then return dfastate_19
+ if c.ascii == 69 then return dfastate_19
+ if c.ascii == 70 then return dfastate_19
+ if c.ascii == 71 then return dfastate_19
+ if c.ascii == 72 then return dfastate_19
+ if c.ascii == 73 then return dfastate_19
+ if c.ascii == 74 then return dfastate_19
+ if c.ascii == 75 then return dfastate_19
+ if c.ascii == 76 then return dfastate_19
+ if c.ascii == 77 then return dfastate_19
+ if c.ascii == 78 then return dfastate_19
+ if c.ascii == 79 then return dfastate_19
+ if c.ascii == 80 then return dfastate_19
+ if c.ascii == 81 then return dfastate_19
+ if c.ascii == 82 then return dfastate_19
+ if c.ascii == 83 then return dfastate_19
+ if c.ascii == 84 then return dfastate_19
+ if c.ascii == 85 then return dfastate_19
+ if c.ascii == 86 then return dfastate_19
+ if c.ascii == 87 then return dfastate_19
+ if c.ascii == 88 then return dfastate_19
+ if c.ascii == 89 then return dfastate_19
+ if c.ascii == 90 then return dfastate_19
+ return null
+ end
+end
+class DFAState7
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nid
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 95 then return dfastate_16
+ if c.ascii == 48 then return dfastate_17
+ if c.ascii == 49 then return dfastate_17
+ if c.ascii == 50 then return dfastate_17
+ if c.ascii == 51 then return dfastate_17
+ if c.ascii == 52 then return dfastate_17
+ if c.ascii == 53 then return dfastate_17
+ if c.ascii == 54 then return dfastate_17
+ if c.ascii == 55 then return dfastate_17
+ if c.ascii == 56 then return dfastate_17
+ if c.ascii == 57 then return dfastate_17
+ if c.ascii == 97 then return dfastate_18
+ if c.ascii == 98 then return dfastate_18
+ if c.ascii == 99 then return dfastate_18
+ if c.ascii == 100 then return dfastate_18
+ if c.ascii == 101 then return dfastate_18
+ if c.ascii == 102 then return dfastate_18
+ if c.ascii == 103 then return dfastate_18
+ if c.ascii == 104 then return dfastate_18
+ if c.ascii == 105 then return dfastate_18
+ if c.ascii == 106 then return dfastate_18
+ if c.ascii == 107 then return dfastate_18
+ if c.ascii == 108 then return dfastate_18
+ if c.ascii == 109 then return dfastate_18
+ if c.ascii == 110 then return dfastate_18
+ if c.ascii == 111 then return dfastate_18
+ if c.ascii == 112 then return dfastate_18
+ if c.ascii == 113 then return dfastate_18
+ if c.ascii == 114 then return dfastate_18
+ if c.ascii == 115 then return dfastate_18
+ if c.ascii == 116 then return dfastate_18
+ if c.ascii == 117 then return dfastate_18
+ if c.ascii == 118 then return dfastate_18
+ if c.ascii == 119 then return dfastate_18
+ if c.ascii == 120 then return dfastate_18
+ if c.ascii == 121 then return dfastate_18
+ if c.ascii == 122 then return dfastate_18
+ if c.ascii == 65 then return dfastate_19
+ if c.ascii == 66 then return dfastate_19
+ if c.ascii == 67 then return dfastate_19
+ if c.ascii == 68 then return dfastate_19
+ if c.ascii == 69 then return dfastate_19
+ if c.ascii == 70 then return dfastate_19
+ if c.ascii == 71 then return dfastate_19
+ if c.ascii == 72 then return dfastate_19
+ if c.ascii == 73 then return dfastate_19
+ if c.ascii == 74 then return dfastate_19
+ if c.ascii == 75 then return dfastate_19
+ if c.ascii == 76 then return dfastate_19
+ if c.ascii == 77 then return dfastate_19
+ if c.ascii == 78 then return dfastate_19
+ if c.ascii == 79 then return dfastate_19
+ if c.ascii == 80 then return dfastate_19
+ if c.ascii == 81 then return dfastate_19
+ if c.ascii == 82 then return dfastate_19
+ if c.ascii == 83 then return dfastate_19
+ if c.ascii == 84 then return dfastate_19
+ if c.ascii == 85 then return dfastate_19
+ if c.ascii == 86 then return dfastate_19
+ if c.ascii == 87 then return dfastate_19
+ if c.ascii == 88 then return dfastate_19
+ if c.ascii == 89 then return dfastate_19
+ if c.ascii == 90 then return dfastate_19
+ return null
+ end
+end
+class DFAState8
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nid
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 95 then return dfastate_16
+ if c.ascii == 48 then return dfastate_17
+ if c.ascii == 49 then return dfastate_17
+ if c.ascii == 50 then return dfastate_17
+ if c.ascii == 51 then return dfastate_17
+ if c.ascii == 52 then return dfastate_17
+ if c.ascii == 53 then return dfastate_17
+ if c.ascii == 54 then return dfastate_17
+ if c.ascii == 55 then return dfastate_17
+ if c.ascii == 56 then return dfastate_17
+ if c.ascii == 57 then return dfastate_17
+ if c.ascii == 97 then return dfastate_18
+ if c.ascii == 98 then return dfastate_18
+ if c.ascii == 99 then return dfastate_18
+ if c.ascii == 100 then return dfastate_18
+ if c.ascii == 101 then return dfastate_18
+ if c.ascii == 102 then return dfastate_18
+ if c.ascii == 103 then return dfastate_18
+ if c.ascii == 104 then return dfastate_18
+ if c.ascii == 105 then return dfastate_18
+ if c.ascii == 106 then return dfastate_18
+ if c.ascii == 107 then return dfastate_18
+ if c.ascii == 108 then return dfastate_18
+ if c.ascii == 109 then return dfastate_18
+ if c.ascii == 110 then return dfastate_18
+ if c.ascii == 111 then return dfastate_18
+ if c.ascii == 112 then return dfastate_18
+ if c.ascii == 113 then return dfastate_18
+ if c.ascii == 114 then return dfastate_18
+ if c.ascii == 115 then return dfastate_18
+ if c.ascii == 116 then return dfastate_18
+ if c.ascii == 117 then return dfastate_18
+ if c.ascii == 118 then return dfastate_18
+ if c.ascii == 119 then return dfastate_18
+ if c.ascii == 120 then return dfastate_18
+ if c.ascii == 121 then return dfastate_18
+ if c.ascii == 122 then return dfastate_18
+ if c.ascii == 65 then return dfastate_19
+ if c.ascii == 66 then return dfastate_19
+ if c.ascii == 67 then return dfastate_19
+ if c.ascii == 68 then return dfastate_19
+ if c.ascii == 69 then return dfastate_19
+ if c.ascii == 70 then return dfastate_19
+ if c.ascii == 71 then return dfastate_19
+ if c.ascii == 72 then return dfastate_19
+ if c.ascii == 73 then return dfastate_19
+ if c.ascii == 74 then return dfastate_19
+ if c.ascii == 75 then return dfastate_19
+ if c.ascii == 76 then return dfastate_19
+ if c.ascii == 77 then return dfastate_19
+ if c.ascii == 78 then return dfastate_19
+ if c.ascii == 79 then return dfastate_19
+ if c.ascii == 80 then return dfastate_19
+ if c.ascii == 81 then return dfastate_19
+ if c.ascii == 82 then return dfastate_19
+ if c.ascii == 83 then return dfastate_19
+ if c.ascii == 84 then return dfastate_19
+ if c.ascii == 85 then return dfastate_19
+ if c.ascii == 86 then return dfastate_19
+ if c.ascii == 87 then return dfastate_19
+ if c.ascii == 88 then return dfastate_19
+ if c.ascii == 89 then return dfastate_19
+ if c.ascii == 90 then return dfastate_19
+ return null
+ end
+end
+class DFAState9
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Neol
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState10
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Neol
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 13 then return dfastate_15
+ return null
+ end
+end
+class DFAState11
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ncomment
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_14
+ if c.ascii == 33 then return dfastate_14
+ if c.ascii == 34 then return dfastate_14
+ if c.ascii == 35 then return dfastate_14
+ if c.ascii == 36 then return dfastate_14
+ if c.ascii == 37 then return dfastate_14
+ if c.ascii == 38 then return dfastate_14
+ if c.ascii == 39 then return dfastate_14
+ if c.ascii == 40 then return dfastate_14
+ if c.ascii == 41 then return dfastate_14
+ if c.ascii == 42 then return dfastate_14
+ if c.ascii == 43 then return dfastate_14
+ if c.ascii == 44 then return dfastate_14
+ if c.ascii == 45 then return dfastate_14
+ if c.ascii == 46 then return dfastate_14
+ if c.ascii == 47 then return dfastate_14
+ if c.ascii == 48 then return dfastate_14
+ if c.ascii == 49 then return dfastate_14
+ if c.ascii == 50 then return dfastate_14
+ if c.ascii == 51 then return dfastate_14
+ if c.ascii == 52 then return dfastate_14
+ if c.ascii == 53 then return dfastate_14
+ if c.ascii == 54 then return dfastate_14
+ if c.ascii == 55 then return dfastate_14
+ if c.ascii == 56 then return dfastate_14
+ if c.ascii == 57 then return dfastate_14
+ if c.ascii == 58 then return dfastate_14
+ if c.ascii == 59 then return dfastate_14
+ if c.ascii == 60 then return dfastate_14
+ if c.ascii == 61 then return dfastate_14
+ if c.ascii == 62 then return dfastate_14
+ if c.ascii == 63 then return dfastate_14
+ if c.ascii == 64 then return dfastate_14
+ if c.ascii == 65 then return dfastate_14
+ if c.ascii == 66 then return dfastate_14
+ if c.ascii == 67 then return dfastate_14
+ if c.ascii == 68 then return dfastate_14
+ if c.ascii == 69 then return dfastate_14
+ if c.ascii == 70 then return dfastate_14
+ if c.ascii == 71 then return dfastate_14
+ if c.ascii == 72 then return dfastate_14
+ if c.ascii == 73 then return dfastate_14
+ if c.ascii == 74 then return dfastate_14
+ if c.ascii == 75 then return dfastate_14
+ if c.ascii == 76 then return dfastate_14
+ if c.ascii == 77 then return dfastate_14
+ if c.ascii == 78 then return dfastate_14
+ if c.ascii == 79 then return dfastate_14
+ if c.ascii == 80 then return dfastate_14
+ if c.ascii == 81 then return dfastate_14
+ if c.ascii == 82 then return dfastate_14
+ if c.ascii == 83 then return dfastate_14
+ if c.ascii == 84 then return dfastate_14
+ if c.ascii == 85 then return dfastate_14
+ if c.ascii == 86 then return dfastate_14
+ if c.ascii == 87 then return dfastate_14
+ if c.ascii == 88 then return dfastate_14
+ if c.ascii == 89 then return dfastate_14
+ if c.ascii == 90 then return dfastate_14
+ if c.ascii == 91 then return dfastate_14
+ if c.ascii == 92 then return dfastate_14
+ if c.ascii == 93 then return dfastate_14
+ if c.ascii == 94 then return dfastate_14
+ if c.ascii == 95 then return dfastate_14
+ if c.ascii == 96 then return dfastate_14
+ if c.ascii == 97 then return dfastate_14
+ if c.ascii == 98 then return dfastate_14
+ if c.ascii == 99 then return dfastate_14
+ if c.ascii == 100 then return dfastate_14
+ if c.ascii == 101 then return dfastate_14
+ if c.ascii == 102 then return dfastate_14
+ if c.ascii == 103 then return dfastate_14
+ if c.ascii == 104 then return dfastate_14
+ if c.ascii == 105 then return dfastate_14
+ if c.ascii == 106 then return dfastate_14
+ if c.ascii == 107 then return dfastate_14
+ if c.ascii == 108 then return dfastate_14
+ if c.ascii == 109 then return dfastate_14
+ if c.ascii == 110 then return dfastate_14
+ if c.ascii == 111 then return dfastate_14
+ if c.ascii == 112 then return dfastate_14
+ if c.ascii == 113 then return dfastate_14
+ if c.ascii == 114 then return dfastate_14
+ if c.ascii == 115 then return dfastate_14
+ if c.ascii == 116 then return dfastate_14
+ if c.ascii == 117 then return dfastate_14
+ if c.ascii == 118 then return dfastate_14
+ if c.ascii == 119 then return dfastate_14
+ if c.ascii == 120 then return dfastate_14
+ if c.ascii == 121 then return dfastate_14
+ if c.ascii == 122 then return dfastate_14
+ if c.ascii == 123 then return dfastate_14
+ if c.ascii == 124 then return dfastate_14
+ if c.ascii == 125 then return dfastate_14
+ if c.ascii == 126 then return dfastate_14
+ return null
+ end
+end
+class DFAState12
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ return null
+ end
+ redef fun trans(c) do
+ if c.ascii == 9 then return dfastate_12
+ if c.ascii == 32 then return dfastate_13
+ return null
+ end
+end
+class DFAState13
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ return null
+ end
+ redef fun trans(c) do
+ if c.ascii == 9 then return dfastate_12
+ if c.ascii == 32 then return dfastate_13
+ return null
+ end
+end
+class DFAState14
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ncomment
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_14
+ if c.ascii == 33 then return dfastate_14
+ if c.ascii == 34 then return dfastate_14
+ if c.ascii == 35 then return dfastate_14
+ if c.ascii == 36 then return dfastate_14
+ if c.ascii == 37 then return dfastate_14
+ if c.ascii == 38 then return dfastate_14
+ if c.ascii == 39 then return dfastate_14
+ if c.ascii == 40 then return dfastate_14
+ if c.ascii == 41 then return dfastate_14
+ if c.ascii == 42 then return dfastate_14
+ if c.ascii == 43 then return dfastate_14
+ if c.ascii == 44 then return dfastate_14
+ if c.ascii == 45 then return dfastate_14
+ if c.ascii == 46 then return dfastate_14
+ if c.ascii == 47 then return dfastate_14
+ if c.ascii == 48 then return dfastate_14
+ if c.ascii == 49 then return dfastate_14
+ if c.ascii == 50 then return dfastate_14
+ if c.ascii == 51 then return dfastate_14
+ if c.ascii == 52 then return dfastate_14
+ if c.ascii == 53 then return dfastate_14
+ if c.ascii == 54 then return dfastate_14
+ if c.ascii == 55 then return dfastate_14
+ if c.ascii == 56 then return dfastate_14
+ if c.ascii == 57 then return dfastate_14
+ if c.ascii == 58 then return dfastate_14
+ if c.ascii == 59 then return dfastate_14
+ if c.ascii == 60 then return dfastate_14
+ if c.ascii == 61 then return dfastate_14
+ if c.ascii == 62 then return dfastate_14
+ if c.ascii == 63 then return dfastate_14
+ if c.ascii == 64 then return dfastate_14
+ if c.ascii == 65 then return dfastate_14
+ if c.ascii == 66 then return dfastate_14
+ if c.ascii == 67 then return dfastate_14
+ if c.ascii == 68 then return dfastate_14
+ if c.ascii == 69 then return dfastate_14
+ if c.ascii == 70 then return dfastate_14
+ if c.ascii == 71 then return dfastate_14
+ if c.ascii == 72 then return dfastate_14
+ if c.ascii == 73 then return dfastate_14
+ if c.ascii == 74 then return dfastate_14
+ if c.ascii == 75 then return dfastate_14
+ if c.ascii == 76 then return dfastate_14
+ if c.ascii == 77 then return dfastate_14
+ if c.ascii == 78 then return dfastate_14
+ if c.ascii == 79 then return dfastate_14
+ if c.ascii == 80 then return dfastate_14
+ if c.ascii == 81 then return dfastate_14
+ if c.ascii == 82 then return dfastate_14
+ if c.ascii == 83 then return dfastate_14
+ if c.ascii == 84 then return dfastate_14
+ if c.ascii == 85 then return dfastate_14
+ if c.ascii == 86 then return dfastate_14
+ if c.ascii == 87 then return dfastate_14
+ if c.ascii == 88 then return dfastate_14
+ if c.ascii == 89 then return dfastate_14
+ if c.ascii == 90 then return dfastate_14
+ if c.ascii == 91 then return dfastate_14
+ if c.ascii == 92 then return dfastate_14
+ if c.ascii == 93 then return dfastate_14
+ if c.ascii == 94 then return dfastate_14
+ if c.ascii == 95 then return dfastate_14
+ if c.ascii == 96 then return dfastate_14
+ if c.ascii == 97 then return dfastate_14
+ if c.ascii == 98 then return dfastate_14
+ if c.ascii == 99 then return dfastate_14
+ if c.ascii == 100 then return dfastate_14
+ if c.ascii == 101 then return dfastate_14
+ if c.ascii == 102 then return dfastate_14
+ if c.ascii == 103 then return dfastate_14
+ if c.ascii == 104 then return dfastate_14
+ if c.ascii == 105 then return dfastate_14
+ if c.ascii == 106 then return dfastate_14
+ if c.ascii == 107 then return dfastate_14
+ if c.ascii == 108 then return dfastate_14
+ if c.ascii == 109 then return dfastate_14
+ if c.ascii == 110 then return dfastate_14
+ if c.ascii == 111 then return dfastate_14
+ if c.ascii == 112 then return dfastate_14
+ if c.ascii == 113 then return dfastate_14
+ if c.ascii == 114 then return dfastate_14
+ if c.ascii == 115 then return dfastate_14
+ if c.ascii == 116 then return dfastate_14
+ if c.ascii == 117 then return dfastate_14
+ if c.ascii == 118 then return dfastate_14
+ if c.ascii == 119 then return dfastate_14
+ if c.ascii == 120 then return dfastate_14
+ if c.ascii == 121 then return dfastate_14
+ if c.ascii == 122 then return dfastate_14
+ if c.ascii == 123 then return dfastate_14
+ if c.ascii == 124 then return dfastate_14
+ if c.ascii == 125 then return dfastate_14
+ if c.ascii == 126 then return dfastate_14
+ return null
+ end
+end
+class DFAState15
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Neol
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState16
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nid
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 95 then return dfastate_16
+ if c.ascii == 48 then return dfastate_17
+ if c.ascii == 49 then return dfastate_17
+ if c.ascii == 50 then return dfastate_17
+ if c.ascii == 51 then return dfastate_17
+ if c.ascii == 52 then return dfastate_17
+ if c.ascii == 53 then return dfastate_17
+ if c.ascii == 54 then return dfastate_17
+ if c.ascii == 55 then return dfastate_17
+ if c.ascii == 56 then return dfastate_17
+ if c.ascii == 57 then return dfastate_17
+ if c.ascii == 97 then return dfastate_18
+ if c.ascii == 98 then return dfastate_18
+ if c.ascii == 99 then return dfastate_18
+ if c.ascii == 100 then return dfastate_18
+ if c.ascii == 101 then return dfastate_18
+ if c.ascii == 102 then return dfastate_18
+ if c.ascii == 103 then return dfastate_18
+ if c.ascii == 104 then return dfastate_18
+ if c.ascii == 105 then return dfastate_18
+ if c.ascii == 106 then return dfastate_18
+ if c.ascii == 107 then return dfastate_18
+ if c.ascii == 108 then return dfastate_18
+ if c.ascii == 109 then return dfastate_18
+ if c.ascii == 110 then return dfastate_18
+ if c.ascii == 111 then return dfastate_18
+ if c.ascii == 112 then return dfastate_18
+ if c.ascii == 113 then return dfastate_18
+ if c.ascii == 114 then return dfastate_18
+ if c.ascii == 115 then return dfastate_18
+ if c.ascii == 116 then return dfastate_18
+ if c.ascii == 117 then return dfastate_18
+ if c.ascii == 118 then return dfastate_18
+ if c.ascii == 119 then return dfastate_18
+ if c.ascii == 120 then return dfastate_18
+ if c.ascii == 121 then return dfastate_18
+ if c.ascii == 122 then return dfastate_18
+ if c.ascii == 65 then return dfastate_19
+ if c.ascii == 66 then return dfastate_19
+ if c.ascii == 67 then return dfastate_19
+ if c.ascii == 68 then return dfastate_19
+ if c.ascii == 69 then return dfastate_19
+ if c.ascii == 70 then return dfastate_19
+ if c.ascii == 71 then return dfastate_19
+ if c.ascii == 72 then return dfastate_19
+ if c.ascii == 73 then return dfastate_19
+ if c.ascii == 74 then return dfastate_19
+ if c.ascii == 75 then return dfastate_19
+ if c.ascii == 76 then return dfastate_19
+ if c.ascii == 77 then return dfastate_19
+ if c.ascii == 78 then return dfastate_19
+ if c.ascii == 79 then return dfastate_19
+ if c.ascii == 80 then return dfastate_19
+ if c.ascii == 81 then return dfastate_19
+ if c.ascii == 82 then return dfastate_19
+ if c.ascii == 83 then return dfastate_19
+ if c.ascii == 84 then return dfastate_19
+ if c.ascii == 85 then return dfastate_19
+ if c.ascii == 86 then return dfastate_19
+ if c.ascii == 87 then return dfastate_19
+ if c.ascii == 88 then return dfastate_19
+ if c.ascii == 89 then return dfastate_19
+ if c.ascii == 90 then return dfastate_19
+ return null
+ end
+end
+class DFAState17
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nid
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 95 then return dfastate_16
+ if c.ascii == 48 then return dfastate_17
+ if c.ascii == 49 then return dfastate_17
+ if c.ascii == 50 then return dfastate_17
+ if c.ascii == 51 then return dfastate_17
+ if c.ascii == 52 then return dfastate_17
+ if c.ascii == 53 then return dfastate_17
+ if c.ascii == 54 then return dfastate_17
+ if c.ascii == 55 then return dfastate_17
+ if c.ascii == 56 then return dfastate_17
+ if c.ascii == 57 then return dfastate_17
+ if c.ascii == 97 then return dfastate_18
+ if c.ascii == 98 then return dfastate_18
+ if c.ascii == 99 then return dfastate_18
+ if c.ascii == 100 then return dfastate_18
+ if c.ascii == 101 then return dfastate_18
+ if c.ascii == 102 then return dfastate_18
+ if c.ascii == 103 then return dfastate_18
+ if c.ascii == 104 then return dfastate_18
+ if c.ascii == 105 then return dfastate_18
+ if c.ascii == 106 then return dfastate_18
+ if c.ascii == 107 then return dfastate_18
+ if c.ascii == 108 then return dfastate_18
+ if c.ascii == 109 then return dfastate_18
+ if c.ascii == 110 then return dfastate_18
+ if c.ascii == 111 then return dfastate_18
+ if c.ascii == 112 then return dfastate_18
+ if c.ascii == 113 then return dfastate_18
+ if c.ascii == 114 then return dfastate_18
+ if c.ascii == 115 then return dfastate_18
+ if c.ascii == 116 then return dfastate_18
+ if c.ascii == 117 then return dfastate_18
+ if c.ascii == 118 then return dfastate_18
+ if c.ascii == 119 then return dfastate_18
+ if c.ascii == 120 then return dfastate_18
+ if c.ascii == 121 then return dfastate_18
+ if c.ascii == 122 then return dfastate_18
+ if c.ascii == 65 then return dfastate_19
+ if c.ascii == 66 then return dfastate_19
+ if c.ascii == 67 then return dfastate_19
+ if c.ascii == 68 then return dfastate_19
+ if c.ascii == 69 then return dfastate_19
+ if c.ascii == 70 then return dfastate_19
+ if c.ascii == 71 then return dfastate_19
+ if c.ascii == 72 then return dfastate_19
+ if c.ascii == 73 then return dfastate_19
+ if c.ascii == 74 then return dfastate_19
+ if c.ascii == 75 then return dfastate_19
+ if c.ascii == 76 then return dfastate_19
+ if c.ascii == 77 then return dfastate_19
+ if c.ascii == 78 then return dfastate_19
+ if c.ascii == 79 then return dfastate_19
+ if c.ascii == 80 then return dfastate_19
+ if c.ascii == 81 then return dfastate_19
+ if c.ascii == 82 then return dfastate_19
+ if c.ascii == 83 then return dfastate_19
+ if c.ascii == 84 then return dfastate_19
+ if c.ascii == 85 then return dfastate_19
+ if c.ascii == 86 then return dfastate_19
+ if c.ascii == 87 then return dfastate_19
+ if c.ascii == 88 then return dfastate_19
+ if c.ascii == 89 then return dfastate_19
+ if c.ascii == 90 then return dfastate_19
+ return null
+ end
+end
+class DFAState18
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nid
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 95 then return dfastate_16
+ if c.ascii == 48 then return dfastate_17
+ if c.ascii == 49 then return dfastate_17
+ if c.ascii == 50 then return dfastate_17
+ if c.ascii == 51 then return dfastate_17
+ if c.ascii == 52 then return dfastate_17
+ if c.ascii == 53 then return dfastate_17
+ if c.ascii == 54 then return dfastate_17
+ if c.ascii == 55 then return dfastate_17
+ if c.ascii == 56 then return dfastate_17
+ if c.ascii == 57 then return dfastate_17
+ if c.ascii == 97 then return dfastate_18
+ if c.ascii == 98 then return dfastate_18
+ if c.ascii == 99 then return dfastate_18
+ if c.ascii == 100 then return dfastate_18
+ if c.ascii == 101 then return dfastate_18
+ if c.ascii == 102 then return dfastate_18
+ if c.ascii == 103 then return dfastate_18
+ if c.ascii == 104 then return dfastate_18
+ if c.ascii == 105 then return dfastate_18
+ if c.ascii == 106 then return dfastate_18
+ if c.ascii == 107 then return dfastate_18
+ if c.ascii == 108 then return dfastate_18
+ if c.ascii == 109 then return dfastate_18
+ if c.ascii == 110 then return dfastate_18
+ if c.ascii == 111 then return dfastate_18
+ if c.ascii == 112 then return dfastate_18
+ if c.ascii == 113 then return dfastate_18
+ if c.ascii == 114 then return dfastate_18
+ if c.ascii == 115 then return dfastate_18
+ if c.ascii == 116 then return dfastate_18
+ if c.ascii == 117 then return dfastate_18
+ if c.ascii == 118 then return dfastate_18
+ if c.ascii == 119 then return dfastate_18
+ if c.ascii == 120 then return dfastate_18
+ if c.ascii == 121 then return dfastate_18
+ if c.ascii == 122 then return dfastate_18
+ if c.ascii == 65 then return dfastate_19
+ if c.ascii == 66 then return dfastate_19
+ if c.ascii == 67 then return dfastate_19
+ if c.ascii == 68 then return dfastate_19
+ if c.ascii == 69 then return dfastate_19
+ if c.ascii == 70 then return dfastate_19
+ if c.ascii == 71 then return dfastate_19
+ if c.ascii == 72 then return dfastate_19
+ if c.ascii == 73 then return dfastate_19
+ if c.ascii == 74 then return dfastate_19
+ if c.ascii == 75 then return dfastate_19
+ if c.ascii == 76 then return dfastate_19
+ if c.ascii == 77 then return dfastate_19
+ if c.ascii == 78 then return dfastate_19
+ if c.ascii == 79 then return dfastate_19
+ if c.ascii == 80 then return dfastate_19
+ if c.ascii == 81 then return dfastate_19
+ if c.ascii == 82 then return dfastate_19
+ if c.ascii == 83 then return dfastate_19
+ if c.ascii == 84 then return dfastate_19
+ if c.ascii == 85 then return dfastate_19
+ if c.ascii == 86 then return dfastate_19
+ if c.ascii == 87 then return dfastate_19
+ if c.ascii == 88 then return dfastate_19
+ if c.ascii == 89 then return dfastate_19
+ if c.ascii == 90 then return dfastate_19
+ return null
+ end
+end
+class DFAState19
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nid
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 95 then return dfastate_16
+ if c.ascii == 48 then return dfastate_17
+ if c.ascii == 49 then return dfastate_17
+ if c.ascii == 50 then return dfastate_17
+ if c.ascii == 51 then return dfastate_17
+ if c.ascii == 52 then return dfastate_17
+ if c.ascii == 53 then return dfastate_17
+ if c.ascii == 54 then return dfastate_17
+ if c.ascii == 55 then return dfastate_17
+ if c.ascii == 56 then return dfastate_17
+ if c.ascii == 57 then return dfastate_17
+ if c.ascii == 97 then return dfastate_18
+ if c.ascii == 98 then return dfastate_18
+ if c.ascii == 99 then return dfastate_18
+ if c.ascii == 100 then return dfastate_18
+ if c.ascii == 101 then return dfastate_18
+ if c.ascii == 102 then return dfastate_18
+ if c.ascii == 103 then return dfastate_18
+ if c.ascii == 104 then return dfastate_18
+ if c.ascii == 105 then return dfastate_18
+ if c.ascii == 106 then return dfastate_18
+ if c.ascii == 107 then return dfastate_18
+ if c.ascii == 108 then return dfastate_18
+ if c.ascii == 109 then return dfastate_18
+ if c.ascii == 110 then return dfastate_18
+ if c.ascii == 111 then return dfastate_18
+ if c.ascii == 112 then return dfastate_18
+ if c.ascii == 113 then return dfastate_18
+ if c.ascii == 114 then return dfastate_18
+ if c.ascii == 115 then return dfastate_18
+ if c.ascii == 116 then return dfastate_18
+ if c.ascii == 117 then return dfastate_18
+ if c.ascii == 118 then return dfastate_18
+ if c.ascii == 119 then return dfastate_18
+ if c.ascii == 120 then return dfastate_18
+ if c.ascii == 121 then return dfastate_18
+ if c.ascii == 122 then return dfastate_18
+ if c.ascii == 65 then return dfastate_19
+ if c.ascii == 66 then return dfastate_19
+ if c.ascii == 67 then return dfastate_19
+ if c.ascii == 68 then return dfastate_19
+ if c.ascii == 69 then return dfastate_19
+ if c.ascii == 70 then return dfastate_19
+ if c.ascii == 71 then return dfastate_19
+ if c.ascii == 72 then return dfastate_19
+ if c.ascii == 73 then return dfastate_19
+ if c.ascii == 74 then return dfastate_19
+ if c.ascii == 75 then return dfastate_19
+ if c.ascii == 76 then return dfastate_19
+ if c.ascii == 77 then return dfastate_19
+ if c.ascii == 78 then return dfastate_19
+ if c.ascii == 79 then return dfastate_19
+ if c.ascii == 80 then return dfastate_19
+ if c.ascii == 81 then return dfastate_19
+ if c.ascii == 82 then return dfastate_19
+ if c.ascii == 83 then return dfastate_19
+ if c.ascii == 84 then return dfastate_19
+ if c.ascii == 85 then return dfastate_19
+ if c.ascii == 86 then return dfastate_19
+ if c.ascii == 87 then return dfastate_19
+ if c.ascii == 88 then return dfastate_19
+ if c.ascii == 89 then return dfastate_19
+ if c.ascii == 90 then return dfastate_19
+ return null
+ end
+end
+class DFAState20
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 39 then return dfastate_32
+ return null
+ end
+end
+class DFAState21
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 120 then return dfastate_22
+ if c.ascii == 32 then return dfastate_23
+ if c.ascii == 33 then return dfastate_23
+ if c.ascii == 34 then return dfastate_23
+ if c.ascii == 35 then return dfastate_23
+ if c.ascii == 36 then return dfastate_23
+ if c.ascii == 37 then return dfastate_23
+ if c.ascii == 38 then return dfastate_23
+ if c.ascii == 39 then return dfastate_23
+ if c.ascii == 40 then return dfastate_23
+ if c.ascii == 41 then return dfastate_23
+ if c.ascii == 42 then return dfastate_23
+ if c.ascii == 43 then return dfastate_23
+ if c.ascii == 44 then return dfastate_23
+ if c.ascii == 45 then return dfastate_23
+ if c.ascii == 46 then return dfastate_23
+ if c.ascii == 47 then return dfastate_23
+ if c.ascii == 48 then return dfastate_23
+ if c.ascii == 49 then return dfastate_23
+ if c.ascii == 50 then return dfastate_23
+ if c.ascii == 51 then return dfastate_23
+ if c.ascii == 52 then return dfastate_23
+ if c.ascii == 53 then return dfastate_23
+ if c.ascii == 54 then return dfastate_23
+ if c.ascii == 55 then return dfastate_23
+ if c.ascii == 56 then return dfastate_23
+ if c.ascii == 57 then return dfastate_23
+ if c.ascii == 58 then return dfastate_23
+ if c.ascii == 59 then return dfastate_23
+ if c.ascii == 60 then return dfastate_23
+ if c.ascii == 61 then return dfastate_23
+ if c.ascii == 62 then return dfastate_23
+ if c.ascii == 63 then return dfastate_23
+ if c.ascii == 64 then return dfastate_23
+ if c.ascii == 65 then return dfastate_23
+ if c.ascii == 66 then return dfastate_23
+ if c.ascii == 67 then return dfastate_23
+ if c.ascii == 68 then return dfastate_23
+ if c.ascii == 69 then return dfastate_23
+ if c.ascii == 70 then return dfastate_23
+ if c.ascii == 71 then return dfastate_23
+ if c.ascii == 72 then return dfastate_23
+ if c.ascii == 73 then return dfastate_23
+ if c.ascii == 74 then return dfastate_23
+ if c.ascii == 75 then return dfastate_23
+ if c.ascii == 76 then return dfastate_23
+ if c.ascii == 77 then return dfastate_23
+ if c.ascii == 78 then return dfastate_23
+ if c.ascii == 79 then return dfastate_23
+ if c.ascii == 80 then return dfastate_23
+ if c.ascii == 81 then return dfastate_23
+ if c.ascii == 82 then return dfastate_23
+ if c.ascii == 83 then return dfastate_23
+ if c.ascii == 84 then return dfastate_23
+ if c.ascii == 85 then return dfastate_23
+ if c.ascii == 86 then return dfastate_23
+ if c.ascii == 87 then return dfastate_23
+ if c.ascii == 88 then return dfastate_23
+ if c.ascii == 89 then return dfastate_23
+ if c.ascii == 90 then return dfastate_23
+ if c.ascii == 91 then return dfastate_23
+ if c.ascii == 92 then return dfastate_23
+ if c.ascii == 93 then return dfastate_23
+ if c.ascii == 94 then return dfastate_23
+ if c.ascii == 95 then return dfastate_23
+ if c.ascii == 96 then return dfastate_23
+ if c.ascii == 97 then return dfastate_23
+ if c.ascii == 98 then return dfastate_23
+ if c.ascii == 99 then return dfastate_23
+ if c.ascii == 100 then return dfastate_23
+ if c.ascii == 101 then return dfastate_23
+ if c.ascii == 102 then return dfastate_23
+ if c.ascii == 103 then return dfastate_23
+ if c.ascii == 104 then return dfastate_23
+ if c.ascii == 105 then return dfastate_23
+ if c.ascii == 106 then return dfastate_23
+ if c.ascii == 107 then return dfastate_23
+ if c.ascii == 108 then return dfastate_23
+ if c.ascii == 109 then return dfastate_23
+ if c.ascii == 110 then return dfastate_23
+ if c.ascii == 111 then return dfastate_23
+ if c.ascii == 112 then return dfastate_23
+ if c.ascii == 113 then return dfastate_23
+ if c.ascii == 114 then return dfastate_23
+ if c.ascii == 115 then return dfastate_23
+ if c.ascii == 116 then return dfastate_23
+ if c.ascii == 117 then return dfastate_23
+ if c.ascii == 118 then return dfastate_23
+ if c.ascii == 119 then return dfastate_23
+ if c.ascii == 121 then return dfastate_23
+ if c.ascii == 122 then return dfastate_23
+ if c.ascii == 123 then return dfastate_23
+ if c.ascii == 124 then return dfastate_23
+ if c.ascii == 125 then return dfastate_23
+ if c.ascii == 126 then return dfastate_23
+ return null
+ end
+end
+class DFAState22
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 39 then return dfastate_24
+ if c.ascii == 97 then return dfastate_25
+ if c.ascii == 98 then return dfastate_25
+ if c.ascii == 99 then return dfastate_25
+ if c.ascii == 100 then return dfastate_25
+ if c.ascii == 101 then return dfastate_25
+ if c.ascii == 102 then return dfastate_25
+ if c.ascii == 48 then return dfastate_26
+ if c.ascii == 49 then return dfastate_26
+ if c.ascii == 50 then return dfastate_26
+ if c.ascii == 51 then return dfastate_26
+ if c.ascii == 52 then return dfastate_26
+ if c.ascii == 53 then return dfastate_26
+ if c.ascii == 54 then return dfastate_26
+ if c.ascii == 55 then return dfastate_26
+ if c.ascii == 56 then return dfastate_26
+ if c.ascii == 57 then return dfastate_26
+ if c.ascii == 65 then return dfastate_27
+ if c.ascii == 66 then return dfastate_27
+ if c.ascii == 67 then return dfastate_27
+ if c.ascii == 68 then return dfastate_27
+ if c.ascii == 69 then return dfastate_27
+ if c.ascii == 70 then return dfastate_27
+ return null
+ end
+end
+class DFAState23
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 39 then return dfastate_24
+ return null
+ end
+end
+class DFAState24
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nchar
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState25
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 97 then return dfastate_28
+ if c.ascii == 98 then return dfastate_28
+ if c.ascii == 99 then return dfastate_28
+ if c.ascii == 100 then return dfastate_28
+ if c.ascii == 101 then return dfastate_28
+ if c.ascii == 102 then return dfastate_28
+ if c.ascii == 48 then return dfastate_29
+ if c.ascii == 49 then return dfastate_29
+ if c.ascii == 50 then return dfastate_29
+ if c.ascii == 51 then return dfastate_29
+ if c.ascii == 52 then return dfastate_29
+ if c.ascii == 53 then return dfastate_29
+ if c.ascii == 54 then return dfastate_29
+ if c.ascii == 55 then return dfastate_29
+ if c.ascii == 56 then return dfastate_29
+ if c.ascii == 57 then return dfastate_29
+ if c.ascii == 65 then return dfastate_30
+ if c.ascii == 66 then return dfastate_30
+ if c.ascii == 67 then return dfastate_30
+ if c.ascii == 68 then return dfastate_30
+ if c.ascii == 69 then return dfastate_30
+ if c.ascii == 70 then return dfastate_30
+ return null
+ end
+end
+class DFAState26
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 97 then return dfastate_28
+ if c.ascii == 98 then return dfastate_28
+ if c.ascii == 99 then return dfastate_28
+ if c.ascii == 100 then return dfastate_28
+ if c.ascii == 101 then return dfastate_28
+ if c.ascii == 102 then return dfastate_28
+ if c.ascii == 48 then return dfastate_29
+ if c.ascii == 49 then return dfastate_29
+ if c.ascii == 50 then return dfastate_29
+ if c.ascii == 51 then return dfastate_29
+ if c.ascii == 52 then return dfastate_29
+ if c.ascii == 53 then return dfastate_29
+ if c.ascii == 54 then return dfastate_29
+ if c.ascii == 55 then return dfastate_29
+ if c.ascii == 56 then return dfastate_29
+ if c.ascii == 57 then return dfastate_29
+ if c.ascii == 65 then return dfastate_30
+ if c.ascii == 66 then return dfastate_30
+ if c.ascii == 67 then return dfastate_30
+ if c.ascii == 68 then return dfastate_30
+ if c.ascii == 69 then return dfastate_30
+ if c.ascii == 70 then return dfastate_30
+ return null
+ end
+end
+class DFAState27
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 97 then return dfastate_28
+ if c.ascii == 98 then return dfastate_28
+ if c.ascii == 99 then return dfastate_28
+ if c.ascii == 100 then return dfastate_28
+ if c.ascii == 101 then return dfastate_28
+ if c.ascii == 102 then return dfastate_28
+ if c.ascii == 48 then return dfastate_29
+ if c.ascii == 49 then return dfastate_29
+ if c.ascii == 50 then return dfastate_29
+ if c.ascii == 51 then return dfastate_29
+ if c.ascii == 52 then return dfastate_29
+ if c.ascii == 53 then return dfastate_29
+ if c.ascii == 54 then return dfastate_29
+ if c.ascii == 55 then return dfastate_29
+ if c.ascii == 56 then return dfastate_29
+ if c.ascii == 57 then return dfastate_29
+ if c.ascii == 65 then return dfastate_30
+ if c.ascii == 66 then return dfastate_30
+ if c.ascii == 67 then return dfastate_30
+ if c.ascii == 68 then return dfastate_30
+ if c.ascii == 69 then return dfastate_30
+ if c.ascii == 70 then return dfastate_30
+ return null
+ end
+end
+class DFAState28
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 39 then return dfastate_31
+ return null
+ end
+end
+class DFAState29
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 39 then return dfastate_31
+ return null
+ end
+end
+class DFAState30
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 39 then return dfastate_31
+ return null
+ end
+end
+class DFAState31
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nchar
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState32
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nchar
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState33
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_33
+ if c.ascii == 33 then return dfastate_33
+ if c.ascii == 35 then return dfastate_33
+ if c.ascii == 36 then return dfastate_33
+ if c.ascii == 37 then return dfastate_33
+ if c.ascii == 38 then return dfastate_33
+ if c.ascii == 39 then return dfastate_33
+ if c.ascii == 40 then return dfastate_33
+ if c.ascii == 41 then return dfastate_33
+ if c.ascii == 42 then return dfastate_33
+ if c.ascii == 43 then return dfastate_33
+ if c.ascii == 44 then return dfastate_33
+ if c.ascii == 45 then return dfastate_33
+ if c.ascii == 46 then return dfastate_33
+ if c.ascii == 47 then return dfastate_33
+ if c.ascii == 48 then return dfastate_33
+ if c.ascii == 49 then return dfastate_33
+ if c.ascii == 50 then return dfastate_33
+ if c.ascii == 51 then return dfastate_33
+ if c.ascii == 52 then return dfastate_33
+ if c.ascii == 53 then return dfastate_33
+ if c.ascii == 54 then return dfastate_33
+ if c.ascii == 55 then return dfastate_33
+ if c.ascii == 56 then return dfastate_33
+ if c.ascii == 57 then return dfastate_33
+ if c.ascii == 58 then return dfastate_33
+ if c.ascii == 59 then return dfastate_33
+ if c.ascii == 60 then return dfastate_33
+ if c.ascii == 61 then return dfastate_33
+ if c.ascii == 62 then return dfastate_33
+ if c.ascii == 63 then return dfastate_33
+ if c.ascii == 64 then return dfastate_33
+ if c.ascii == 65 then return dfastate_33
+ if c.ascii == 66 then return dfastate_33
+ if c.ascii == 67 then return dfastate_33
+ if c.ascii == 68 then return dfastate_33
+ if c.ascii == 69 then return dfastate_33
+ if c.ascii == 70 then return dfastate_33
+ if c.ascii == 71 then return dfastate_33
+ if c.ascii == 72 then return dfastate_33
+ if c.ascii == 73 then return dfastate_33
+ if c.ascii == 74 then return dfastate_33
+ if c.ascii == 75 then return dfastate_33
+ if c.ascii == 76 then return dfastate_33
+ if c.ascii == 77 then return dfastate_33
+ if c.ascii == 78 then return dfastate_33
+ if c.ascii == 79 then return dfastate_33
+ if c.ascii == 80 then return dfastate_33
+ if c.ascii == 81 then return dfastate_33
+ if c.ascii == 82 then return dfastate_33
+ if c.ascii == 83 then return dfastate_33
+ if c.ascii == 84 then return dfastate_33
+ if c.ascii == 85 then return dfastate_33
+ if c.ascii == 86 then return dfastate_33
+ if c.ascii == 87 then return dfastate_33
+ if c.ascii == 88 then return dfastate_33
+ if c.ascii == 89 then return dfastate_33
+ if c.ascii == 90 then return dfastate_33
+ if c.ascii == 91 then return dfastate_33
+ if c.ascii == 92 then return dfastate_42
+ if c.ascii == 93 then return dfastate_33
+ if c.ascii == 94 then return dfastate_33
+ if c.ascii == 95 then return dfastate_33
+ if c.ascii == 96 then return dfastate_33
+ if c.ascii == 97 then return dfastate_33
+ if c.ascii == 98 then return dfastate_33
+ if c.ascii == 99 then return dfastate_33
+ if c.ascii == 100 then return dfastate_33
+ if c.ascii == 101 then return dfastate_33
+ if c.ascii == 102 then return dfastate_33
+ if c.ascii == 103 then return dfastate_33
+ if c.ascii == 104 then return dfastate_33
+ if c.ascii == 105 then return dfastate_33
+ if c.ascii == 106 then return dfastate_33
+ if c.ascii == 107 then return dfastate_33
+ if c.ascii == 108 then return dfastate_33
+ if c.ascii == 109 then return dfastate_33
+ if c.ascii == 110 then return dfastate_33
+ if c.ascii == 111 then return dfastate_33
+ if c.ascii == 112 then return dfastate_33
+ if c.ascii == 113 then return dfastate_33
+ if c.ascii == 114 then return dfastate_33
+ if c.ascii == 115 then return dfastate_33
+ if c.ascii == 116 then return dfastate_33
+ if c.ascii == 117 then return dfastate_33
+ if c.ascii == 118 then return dfastate_33
+ if c.ascii == 119 then return dfastate_33
+ if c.ascii == 120 then return dfastate_33
+ if c.ascii == 121 then return dfastate_33
+ if c.ascii == 122 then return dfastate_33
+ if c.ascii == 123 then return dfastate_33
+ if c.ascii == 124 then return dfastate_33
+ if c.ascii == 125 then return dfastate_33
+ if c.ascii == 126 then return dfastate_33
+ return null
+ end
+end
+class DFAState34
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_36
+ if c.ascii == 33 then return dfastate_36
+ if c.ascii == 34 then return dfastate_37
+ if c.ascii == 35 then return dfastate_36
+ if c.ascii == 36 then return dfastate_36
+ if c.ascii == 37 then return dfastate_36
+ if c.ascii == 38 then return dfastate_36
+ if c.ascii == 39 then return dfastate_36
+ if c.ascii == 40 then return dfastate_36
+ if c.ascii == 41 then return dfastate_36
+ if c.ascii == 42 then return dfastate_36
+ if c.ascii == 43 then return dfastate_36
+ if c.ascii == 44 then return dfastate_36
+ if c.ascii == 45 then return dfastate_36
+ if c.ascii == 46 then return dfastate_36
+ if c.ascii == 47 then return dfastate_36
+ if c.ascii == 48 then return dfastate_36
+ if c.ascii == 49 then return dfastate_36
+ if c.ascii == 50 then return dfastate_36
+ if c.ascii == 51 then return dfastate_36
+ if c.ascii == 52 then return dfastate_36
+ if c.ascii == 53 then return dfastate_36
+ if c.ascii == 54 then return dfastate_36
+ if c.ascii == 55 then return dfastate_36
+ if c.ascii == 56 then return dfastate_36
+ if c.ascii == 57 then return dfastate_36
+ if c.ascii == 58 then return dfastate_36
+ if c.ascii == 59 then return dfastate_36
+ if c.ascii == 60 then return dfastate_36
+ if c.ascii == 61 then return dfastate_36
+ if c.ascii == 62 then return dfastate_36
+ if c.ascii == 63 then return dfastate_36
+ if c.ascii == 64 then return dfastate_36
+ if c.ascii == 65 then return dfastate_36
+ if c.ascii == 66 then return dfastate_36
+ if c.ascii == 67 then return dfastate_36
+ if c.ascii == 68 then return dfastate_36
+ if c.ascii == 69 then return dfastate_36
+ if c.ascii == 70 then return dfastate_36
+ if c.ascii == 71 then return dfastate_36
+ if c.ascii == 72 then return dfastate_36
+ if c.ascii == 73 then return dfastate_36
+ if c.ascii == 74 then return dfastate_36
+ if c.ascii == 75 then return dfastate_36
+ if c.ascii == 76 then return dfastate_36
+ if c.ascii == 77 then return dfastate_36
+ if c.ascii == 78 then return dfastate_36
+ if c.ascii == 79 then return dfastate_36
+ if c.ascii == 80 then return dfastate_36
+ if c.ascii == 81 then return dfastate_36
+ if c.ascii == 82 then return dfastate_36
+ if c.ascii == 83 then return dfastate_36
+ if c.ascii == 84 then return dfastate_36
+ if c.ascii == 85 then return dfastate_36
+ if c.ascii == 86 then return dfastate_36
+ if c.ascii == 87 then return dfastate_36
+ if c.ascii == 88 then return dfastate_36
+ if c.ascii == 89 then return dfastate_36
+ if c.ascii == 90 then return dfastate_36
+ if c.ascii == 91 then return dfastate_36
+ if c.ascii == 92 then return dfastate_38
+ if c.ascii == 93 then return dfastate_36
+ if c.ascii == 94 then return dfastate_36
+ if c.ascii == 95 then return dfastate_36
+ if c.ascii == 96 then return dfastate_36
+ if c.ascii == 97 then return dfastate_36
+ if c.ascii == 98 then return dfastate_36
+ if c.ascii == 99 then return dfastate_36
+ if c.ascii == 100 then return dfastate_36
+ if c.ascii == 101 then return dfastate_36
+ if c.ascii == 102 then return dfastate_36
+ if c.ascii == 103 then return dfastate_36
+ if c.ascii == 104 then return dfastate_36
+ if c.ascii == 105 then return dfastate_36
+ if c.ascii == 106 then return dfastate_36
+ if c.ascii == 107 then return dfastate_36
+ if c.ascii == 108 then return dfastate_36
+ if c.ascii == 109 then return dfastate_36
+ if c.ascii == 110 then return dfastate_36
+ if c.ascii == 111 then return dfastate_36
+ if c.ascii == 112 then return dfastate_36
+ if c.ascii == 113 then return dfastate_36
+ if c.ascii == 114 then return dfastate_36
+ if c.ascii == 115 then return dfastate_36
+ if c.ascii == 116 then return dfastate_36
+ if c.ascii == 117 then return dfastate_36
+ if c.ascii == 118 then return dfastate_36
+ if c.ascii == 119 then return dfastate_36
+ if c.ascii == 120 then return dfastate_36
+ if c.ascii == 121 then return dfastate_36
+ if c.ascii == 122 then return dfastate_36
+ if c.ascii == 123 then return dfastate_36
+ if c.ascii == 124 then return dfastate_36
+ if c.ascii == 125 then return dfastate_36
+ if c.ascii == 126 then return dfastate_36
+ return null
+ end
+end
+class DFAState35
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nstring
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState36
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_33
+ if c.ascii == 33 then return dfastate_33
+ if c.ascii == 35 then return dfastate_33
+ if c.ascii == 36 then return dfastate_33
+ if c.ascii == 37 then return dfastate_33
+ if c.ascii == 38 then return dfastate_33
+ if c.ascii == 39 then return dfastate_33
+ if c.ascii == 40 then return dfastate_33
+ if c.ascii == 41 then return dfastate_33
+ if c.ascii == 42 then return dfastate_33
+ if c.ascii == 43 then return dfastate_33
+ if c.ascii == 44 then return dfastate_33
+ if c.ascii == 45 then return dfastate_33
+ if c.ascii == 46 then return dfastate_33
+ if c.ascii == 47 then return dfastate_33
+ if c.ascii == 48 then return dfastate_33
+ if c.ascii == 49 then return dfastate_33
+ if c.ascii == 50 then return dfastate_33
+ if c.ascii == 51 then return dfastate_33
+ if c.ascii == 52 then return dfastate_33
+ if c.ascii == 53 then return dfastate_33
+ if c.ascii == 54 then return dfastate_33
+ if c.ascii == 55 then return dfastate_33
+ if c.ascii == 56 then return dfastate_33
+ if c.ascii == 57 then return dfastate_33
+ if c.ascii == 58 then return dfastate_33
+ if c.ascii == 59 then return dfastate_33
+ if c.ascii == 60 then return dfastate_33
+ if c.ascii == 61 then return dfastate_33
+ if c.ascii == 62 then return dfastate_33
+ if c.ascii == 63 then return dfastate_33
+ if c.ascii == 64 then return dfastate_33
+ if c.ascii == 65 then return dfastate_33
+ if c.ascii == 66 then return dfastate_33
+ if c.ascii == 67 then return dfastate_33
+ if c.ascii == 68 then return dfastate_33
+ if c.ascii == 69 then return dfastate_33
+ if c.ascii == 70 then return dfastate_33
+ if c.ascii == 71 then return dfastate_33
+ if c.ascii == 72 then return dfastate_33
+ if c.ascii == 73 then return dfastate_33
+ if c.ascii == 74 then return dfastate_33
+ if c.ascii == 75 then return dfastate_33
+ if c.ascii == 76 then return dfastate_33
+ if c.ascii == 77 then return dfastate_33
+ if c.ascii == 78 then return dfastate_33
+ if c.ascii == 79 then return dfastate_33
+ if c.ascii == 80 then return dfastate_33
+ if c.ascii == 81 then return dfastate_33
+ if c.ascii == 82 then return dfastate_33
+ if c.ascii == 83 then return dfastate_33
+ if c.ascii == 84 then return dfastate_33
+ if c.ascii == 85 then return dfastate_33
+ if c.ascii == 86 then return dfastate_33
+ if c.ascii == 87 then return dfastate_33
+ if c.ascii == 88 then return dfastate_33
+ if c.ascii == 89 then return dfastate_33
+ if c.ascii == 90 then return dfastate_33
+ if c.ascii == 91 then return dfastate_33
+ if c.ascii == 92 then return dfastate_39
+ if c.ascii == 93 then return dfastate_33
+ if c.ascii == 94 then return dfastate_33
+ if c.ascii == 95 then return dfastate_33
+ if c.ascii == 96 then return dfastate_33
+ if c.ascii == 97 then return dfastate_33
+ if c.ascii == 98 then return dfastate_33
+ if c.ascii == 99 then return dfastate_33
+ if c.ascii == 100 then return dfastate_33
+ if c.ascii == 101 then return dfastate_33
+ if c.ascii == 102 then return dfastate_33
+ if c.ascii == 103 then return dfastate_33
+ if c.ascii == 104 then return dfastate_33
+ if c.ascii == 105 then return dfastate_33
+ if c.ascii == 106 then return dfastate_33
+ if c.ascii == 107 then return dfastate_33
+ if c.ascii == 108 then return dfastate_33
+ if c.ascii == 109 then return dfastate_33
+ if c.ascii == 110 then return dfastate_33
+ if c.ascii == 111 then return dfastate_33
+ if c.ascii == 112 then return dfastate_33
+ if c.ascii == 113 then return dfastate_33
+ if c.ascii == 114 then return dfastate_33
+ if c.ascii == 115 then return dfastate_33
+ if c.ascii == 116 then return dfastate_33
+ if c.ascii == 117 then return dfastate_33
+ if c.ascii == 118 then return dfastate_33
+ if c.ascii == 119 then return dfastate_33
+ if c.ascii == 120 then return dfastate_33
+ if c.ascii == 121 then return dfastate_33
+ if c.ascii == 122 then return dfastate_33
+ if c.ascii == 123 then return dfastate_33
+ if c.ascii == 124 then return dfastate_33
+ if c.ascii == 125 then return dfastate_33
+ if c.ascii == 126 then return dfastate_33
+ if c.ascii == 34 then return dfastate_35
+ return null
+ end
+end
+class DFAState37
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 34 then return dfastate_35
+ if c.ascii == 32 then return dfastate_33
+ if c.ascii == 33 then return dfastate_33
+ if c.ascii == 35 then return dfastate_33
+ if c.ascii == 36 then return dfastate_33
+ if c.ascii == 37 then return dfastate_33
+ if c.ascii == 38 then return dfastate_33
+ if c.ascii == 39 then return dfastate_33
+ if c.ascii == 40 then return dfastate_33
+ if c.ascii == 41 then return dfastate_33
+ if c.ascii == 42 then return dfastate_33
+ if c.ascii == 43 then return dfastate_33
+ if c.ascii == 44 then return dfastate_33
+ if c.ascii == 45 then return dfastate_33
+ if c.ascii == 46 then return dfastate_33
+ if c.ascii == 47 then return dfastate_33
+ if c.ascii == 48 then return dfastate_33
+ if c.ascii == 49 then return dfastate_33
+ if c.ascii == 50 then return dfastate_33
+ if c.ascii == 51 then return dfastate_33
+ if c.ascii == 52 then return dfastate_33
+ if c.ascii == 53 then return dfastate_33
+ if c.ascii == 54 then return dfastate_33
+ if c.ascii == 55 then return dfastate_33
+ if c.ascii == 56 then return dfastate_33
+ if c.ascii == 57 then return dfastate_33
+ if c.ascii == 58 then return dfastate_33
+ if c.ascii == 59 then return dfastate_33
+ if c.ascii == 60 then return dfastate_33
+ if c.ascii == 61 then return dfastate_33
+ if c.ascii == 62 then return dfastate_33
+ if c.ascii == 63 then return dfastate_33
+ if c.ascii == 64 then return dfastate_33
+ if c.ascii == 65 then return dfastate_33
+ if c.ascii == 66 then return dfastate_33
+ if c.ascii == 67 then return dfastate_33
+ if c.ascii == 68 then return dfastate_33
+ if c.ascii == 69 then return dfastate_33
+ if c.ascii == 70 then return dfastate_33
+ if c.ascii == 71 then return dfastate_33
+ if c.ascii == 72 then return dfastate_33
+ if c.ascii == 73 then return dfastate_33
+ if c.ascii == 74 then return dfastate_33
+ if c.ascii == 75 then return dfastate_33
+ if c.ascii == 76 then return dfastate_33
+ if c.ascii == 77 then return dfastate_33
+ if c.ascii == 78 then return dfastate_33
+ if c.ascii == 79 then return dfastate_33
+ if c.ascii == 80 then return dfastate_33
+ if c.ascii == 81 then return dfastate_33
+ if c.ascii == 82 then return dfastate_33
+ if c.ascii == 83 then return dfastate_33
+ if c.ascii == 84 then return dfastate_33
+ if c.ascii == 85 then return dfastate_33
+ if c.ascii == 86 then return dfastate_33
+ if c.ascii == 87 then return dfastate_33
+ if c.ascii == 88 then return dfastate_33
+ if c.ascii == 89 then return dfastate_33
+ if c.ascii == 90 then return dfastate_33
+ if c.ascii == 91 then return dfastate_33
+ if c.ascii == 92 then return dfastate_34
+ if c.ascii == 93 then return dfastate_33
+ if c.ascii == 94 then return dfastate_33
+ if c.ascii == 95 then return dfastate_33
+ if c.ascii == 96 then return dfastate_33
+ if c.ascii == 97 then return dfastate_33
+ if c.ascii == 98 then return dfastate_33
+ if c.ascii == 99 then return dfastate_33
+ if c.ascii == 100 then return dfastate_33
+ if c.ascii == 101 then return dfastate_33
+ if c.ascii == 102 then return dfastate_33
+ if c.ascii == 103 then return dfastate_33
+ if c.ascii == 104 then return dfastate_33
+ if c.ascii == 105 then return dfastate_33
+ if c.ascii == 106 then return dfastate_33
+ if c.ascii == 107 then return dfastate_33
+ if c.ascii == 108 then return dfastate_33
+ if c.ascii == 109 then return dfastate_33
+ if c.ascii == 110 then return dfastate_33
+ if c.ascii == 111 then return dfastate_33
+ if c.ascii == 112 then return dfastate_33
+ if c.ascii == 113 then return dfastate_33
+ if c.ascii == 114 then return dfastate_33
+ if c.ascii == 115 then return dfastate_33
+ if c.ascii == 116 then return dfastate_33
+ if c.ascii == 117 then return dfastate_33
+ if c.ascii == 118 then return dfastate_33
+ if c.ascii == 119 then return dfastate_33
+ if c.ascii == 120 then return dfastate_33
+ if c.ascii == 121 then return dfastate_33
+ if c.ascii == 122 then return dfastate_33
+ if c.ascii == 123 then return dfastate_33
+ if c.ascii == 124 then return dfastate_33
+ if c.ascii == 125 then return dfastate_33
+ if c.ascii == 126 then return dfastate_33
+ return null
+ end
+end
+class DFAState38
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 34 then return dfastate_35
+ if c.ascii == 32 then return dfastate_33
+ if c.ascii == 33 then return dfastate_33
+ if c.ascii == 35 then return dfastate_33
+ if c.ascii == 36 then return dfastate_33
+ if c.ascii == 37 then return dfastate_33
+ if c.ascii == 38 then return dfastate_33
+ if c.ascii == 39 then return dfastate_33
+ if c.ascii == 40 then return dfastate_33
+ if c.ascii == 41 then return dfastate_33
+ if c.ascii == 42 then return dfastate_33
+ if c.ascii == 43 then return dfastate_33
+ if c.ascii == 44 then return dfastate_33
+ if c.ascii == 45 then return dfastate_33
+ if c.ascii == 46 then return dfastate_33
+ if c.ascii == 47 then return dfastate_33
+ if c.ascii == 48 then return dfastate_33
+ if c.ascii == 49 then return dfastate_33
+ if c.ascii == 50 then return dfastate_33
+ if c.ascii == 51 then return dfastate_33
+ if c.ascii == 52 then return dfastate_33
+ if c.ascii == 53 then return dfastate_33
+ if c.ascii == 54 then return dfastate_33
+ if c.ascii == 55 then return dfastate_33
+ if c.ascii == 56 then return dfastate_33
+ if c.ascii == 57 then return dfastate_33
+ if c.ascii == 58 then return dfastate_33
+ if c.ascii == 59 then return dfastate_33
+ if c.ascii == 60 then return dfastate_33
+ if c.ascii == 61 then return dfastate_33
+ if c.ascii == 62 then return dfastate_33
+ if c.ascii == 63 then return dfastate_33
+ if c.ascii == 64 then return dfastate_33
+ if c.ascii == 65 then return dfastate_33
+ if c.ascii == 66 then return dfastate_33
+ if c.ascii == 67 then return dfastate_33
+ if c.ascii == 68 then return dfastate_33
+ if c.ascii == 69 then return dfastate_33
+ if c.ascii == 70 then return dfastate_33
+ if c.ascii == 71 then return dfastate_33
+ if c.ascii == 72 then return dfastate_33
+ if c.ascii == 73 then return dfastate_33
+ if c.ascii == 74 then return dfastate_33
+ if c.ascii == 75 then return dfastate_33
+ if c.ascii == 76 then return dfastate_33
+ if c.ascii == 77 then return dfastate_33
+ if c.ascii == 78 then return dfastate_33
+ if c.ascii == 79 then return dfastate_33
+ if c.ascii == 80 then return dfastate_33
+ if c.ascii == 81 then return dfastate_33
+ if c.ascii == 82 then return dfastate_33
+ if c.ascii == 83 then return dfastate_33
+ if c.ascii == 84 then return dfastate_33
+ if c.ascii == 85 then return dfastate_33
+ if c.ascii == 86 then return dfastate_33
+ if c.ascii == 87 then return dfastate_33
+ if c.ascii == 88 then return dfastate_33
+ if c.ascii == 89 then return dfastate_33
+ if c.ascii == 90 then return dfastate_33
+ if c.ascii == 91 then return dfastate_33
+ if c.ascii == 92 then return dfastate_39
+ if c.ascii == 93 then return dfastate_33
+ if c.ascii == 94 then return dfastate_33
+ if c.ascii == 95 then return dfastate_33
+ if c.ascii == 96 then return dfastate_33
+ if c.ascii == 97 then return dfastate_33
+ if c.ascii == 98 then return dfastate_33
+ if c.ascii == 99 then return dfastate_33
+ if c.ascii == 100 then return dfastate_33
+ if c.ascii == 101 then return dfastate_33
+ if c.ascii == 102 then return dfastate_33
+ if c.ascii == 103 then return dfastate_33
+ if c.ascii == 104 then return dfastate_33
+ if c.ascii == 105 then return dfastate_33
+ if c.ascii == 106 then return dfastate_33
+ if c.ascii == 107 then return dfastate_33
+ if c.ascii == 108 then return dfastate_33
+ if c.ascii == 109 then return dfastate_33
+ if c.ascii == 110 then return dfastate_33
+ if c.ascii == 111 then return dfastate_33
+ if c.ascii == 112 then return dfastate_33
+ if c.ascii == 113 then return dfastate_33
+ if c.ascii == 114 then return dfastate_33
+ if c.ascii == 115 then return dfastate_33
+ if c.ascii == 116 then return dfastate_33
+ if c.ascii == 117 then return dfastate_33
+ if c.ascii == 118 then return dfastate_33
+ if c.ascii == 119 then return dfastate_33
+ if c.ascii == 120 then return dfastate_33
+ if c.ascii == 121 then return dfastate_33
+ if c.ascii == 122 then return dfastate_33
+ if c.ascii == 123 then return dfastate_33
+ if c.ascii == 124 then return dfastate_33
+ if c.ascii == 125 then return dfastate_33
+ if c.ascii == 126 then return dfastate_33
+ return null
+ end
+end
+class DFAState39
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 34 then return dfastate_40
+ if c.ascii == 32 then return dfastate_36
+ if c.ascii == 33 then return dfastate_36
+ if c.ascii == 35 then return dfastate_36
+ if c.ascii == 36 then return dfastate_36
+ if c.ascii == 37 then return dfastate_36
+ if c.ascii == 38 then return dfastate_36
+ if c.ascii == 39 then return dfastate_36
+ if c.ascii == 40 then return dfastate_36
+ if c.ascii == 41 then return dfastate_36
+ if c.ascii == 42 then return dfastate_36
+ if c.ascii == 43 then return dfastate_36
+ if c.ascii == 44 then return dfastate_36
+ if c.ascii == 45 then return dfastate_36
+ if c.ascii == 46 then return dfastate_36
+ if c.ascii == 47 then return dfastate_36
+ if c.ascii == 48 then return dfastate_36
+ if c.ascii == 49 then return dfastate_36
+ if c.ascii == 50 then return dfastate_36
+ if c.ascii == 51 then return dfastate_36
+ if c.ascii == 52 then return dfastate_36
+ if c.ascii == 53 then return dfastate_36
+ if c.ascii == 54 then return dfastate_36
+ if c.ascii == 55 then return dfastate_36
+ if c.ascii == 56 then return dfastate_36
+ if c.ascii == 57 then return dfastate_36
+ if c.ascii == 58 then return dfastate_36
+ if c.ascii == 59 then return dfastate_36
+ if c.ascii == 60 then return dfastate_36
+ if c.ascii == 61 then return dfastate_36
+ if c.ascii == 62 then return dfastate_36
+ if c.ascii == 63 then return dfastate_36
+ if c.ascii == 64 then return dfastate_36
+ if c.ascii == 65 then return dfastate_36
+ if c.ascii == 66 then return dfastate_36
+ if c.ascii == 67 then return dfastate_36
+ if c.ascii == 68 then return dfastate_36
+ if c.ascii == 69 then return dfastate_36
+ if c.ascii == 70 then return dfastate_36
+ if c.ascii == 71 then return dfastate_36
+ if c.ascii == 72 then return dfastate_36
+ if c.ascii == 73 then return dfastate_36
+ if c.ascii == 74 then return dfastate_36
+ if c.ascii == 75 then return dfastate_36
+ if c.ascii == 76 then return dfastate_36
+ if c.ascii == 77 then return dfastate_36
+ if c.ascii == 78 then return dfastate_36
+ if c.ascii == 79 then return dfastate_36
+ if c.ascii == 80 then return dfastate_36
+ if c.ascii == 81 then return dfastate_36
+ if c.ascii == 82 then return dfastate_36
+ if c.ascii == 83 then return dfastate_36
+ if c.ascii == 84 then return dfastate_36
+ if c.ascii == 85 then return dfastate_36
+ if c.ascii == 86 then return dfastate_36
+ if c.ascii == 87 then return dfastate_36
+ if c.ascii == 88 then return dfastate_36
+ if c.ascii == 89 then return dfastate_36
+ if c.ascii == 90 then return dfastate_36
+ if c.ascii == 91 then return dfastate_36
+ if c.ascii == 92 then return dfastate_41
+ if c.ascii == 93 then return dfastate_36
+ if c.ascii == 94 then return dfastate_36
+ if c.ascii == 95 then return dfastate_36
+ if c.ascii == 96 then return dfastate_36
+ if c.ascii == 97 then return dfastate_36
+ if c.ascii == 98 then return dfastate_36
+ if c.ascii == 99 then return dfastate_36
+ if c.ascii == 100 then return dfastate_36
+ if c.ascii == 101 then return dfastate_36
+ if c.ascii == 102 then return dfastate_36
+ if c.ascii == 103 then return dfastate_36
+ if c.ascii == 104 then return dfastate_36
+ if c.ascii == 105 then return dfastate_36
+ if c.ascii == 106 then return dfastate_36
+ if c.ascii == 107 then return dfastate_36
+ if c.ascii == 108 then return dfastate_36
+ if c.ascii == 109 then return dfastate_36
+ if c.ascii == 110 then return dfastate_36
+ if c.ascii == 111 then return dfastate_36
+ if c.ascii == 112 then return dfastate_36
+ if c.ascii == 113 then return dfastate_36
+ if c.ascii == 114 then return dfastate_36
+ if c.ascii == 115 then return dfastate_36
+ if c.ascii == 116 then return dfastate_36
+ if c.ascii == 117 then return dfastate_36
+ if c.ascii == 118 then return dfastate_36
+ if c.ascii == 119 then return dfastate_36
+ if c.ascii == 120 then return dfastate_36
+ if c.ascii == 121 then return dfastate_36
+ if c.ascii == 122 then return dfastate_36
+ if c.ascii == 123 then return dfastate_36
+ if c.ascii == 124 then return dfastate_36
+ if c.ascii == 125 then return dfastate_36
+ if c.ascii == 126 then return dfastate_36
+ return null
+ end
+end
+class DFAState40
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nstring
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 34 then return dfastate_35
+ if c.ascii == 32 then return dfastate_33
+ if c.ascii == 33 then return dfastate_33
+ if c.ascii == 35 then return dfastate_33
+ if c.ascii == 36 then return dfastate_33
+ if c.ascii == 37 then return dfastate_33
+ if c.ascii == 38 then return dfastate_33
+ if c.ascii == 39 then return dfastate_33
+ if c.ascii == 40 then return dfastate_33
+ if c.ascii == 41 then return dfastate_33
+ if c.ascii == 42 then return dfastate_33
+ if c.ascii == 43 then return dfastate_33
+ if c.ascii == 44 then return dfastate_33
+ if c.ascii == 45 then return dfastate_33
+ if c.ascii == 46 then return dfastate_33
+ if c.ascii == 47 then return dfastate_33
+ if c.ascii == 48 then return dfastate_33
+ if c.ascii == 49 then return dfastate_33
+ if c.ascii == 50 then return dfastate_33
+ if c.ascii == 51 then return dfastate_33
+ if c.ascii == 52 then return dfastate_33
+ if c.ascii == 53 then return dfastate_33
+ if c.ascii == 54 then return dfastate_33
+ if c.ascii == 55 then return dfastate_33
+ if c.ascii == 56 then return dfastate_33
+ if c.ascii == 57 then return dfastate_33
+ if c.ascii == 58 then return dfastate_33
+ if c.ascii == 59 then return dfastate_33
+ if c.ascii == 60 then return dfastate_33
+ if c.ascii == 61 then return dfastate_33
+ if c.ascii == 62 then return dfastate_33
+ if c.ascii == 63 then return dfastate_33
+ if c.ascii == 64 then return dfastate_33
+ if c.ascii == 65 then return dfastate_33
+ if c.ascii == 66 then return dfastate_33
+ if c.ascii == 67 then return dfastate_33
+ if c.ascii == 68 then return dfastate_33
+ if c.ascii == 69 then return dfastate_33
+ if c.ascii == 70 then return dfastate_33
+ if c.ascii == 71 then return dfastate_33
+ if c.ascii == 72 then return dfastate_33
+ if c.ascii == 73 then return dfastate_33
+ if c.ascii == 74 then return dfastate_33
+ if c.ascii == 75 then return dfastate_33
+ if c.ascii == 76 then return dfastate_33
+ if c.ascii == 77 then return dfastate_33
+ if c.ascii == 78 then return dfastate_33
+ if c.ascii == 79 then return dfastate_33
+ if c.ascii == 80 then return dfastate_33
+ if c.ascii == 81 then return dfastate_33
+ if c.ascii == 82 then return dfastate_33
+ if c.ascii == 83 then return dfastate_33
+ if c.ascii == 84 then return dfastate_33
+ if c.ascii == 85 then return dfastate_33
+ if c.ascii == 86 then return dfastate_33
+ if c.ascii == 87 then return dfastate_33
+ if c.ascii == 88 then return dfastate_33
+ if c.ascii == 89 then return dfastate_33
+ if c.ascii == 90 then return dfastate_33
+ if c.ascii == 91 then return dfastate_33
+ if c.ascii == 92 then return dfastate_34
+ if c.ascii == 93 then return dfastate_33
+ if c.ascii == 94 then return dfastate_33
+ if c.ascii == 95 then return dfastate_33
+ if c.ascii == 96 then return dfastate_33
+ if c.ascii == 97 then return dfastate_33
+ if c.ascii == 98 then return dfastate_33
+ if c.ascii == 99 then return dfastate_33
+ if c.ascii == 100 then return dfastate_33
+ if c.ascii == 101 then return dfastate_33
+ if c.ascii == 102 then return dfastate_33
+ if c.ascii == 103 then return dfastate_33
+ if c.ascii == 104 then return dfastate_33
+ if c.ascii == 105 then return dfastate_33
+ if c.ascii == 106 then return dfastate_33
+ if c.ascii == 107 then return dfastate_33
+ if c.ascii == 108 then return dfastate_33
+ if c.ascii == 109 then return dfastate_33
+ if c.ascii == 110 then return dfastate_33
+ if c.ascii == 111 then return dfastate_33
+ if c.ascii == 112 then return dfastate_33
+ if c.ascii == 113 then return dfastate_33
+ if c.ascii == 114 then return dfastate_33
+ if c.ascii == 115 then return dfastate_33
+ if c.ascii == 116 then return dfastate_33
+ if c.ascii == 117 then return dfastate_33
+ if c.ascii == 118 then return dfastate_33
+ if c.ascii == 119 then return dfastate_33
+ if c.ascii == 120 then return dfastate_33
+ if c.ascii == 121 then return dfastate_33
+ if c.ascii == 122 then return dfastate_33
+ if c.ascii == 123 then return dfastate_33
+ if c.ascii == 124 then return dfastate_33
+ if c.ascii == 125 then return dfastate_33
+ if c.ascii == 126 then return dfastate_33
+ return null
+ end
+end
+class DFAState41
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 34 then return dfastate_40
+ if c.ascii == 32 then return dfastate_36
+ if c.ascii == 33 then return dfastate_36
+ if c.ascii == 35 then return dfastate_36
+ if c.ascii == 36 then return dfastate_36
+ if c.ascii == 37 then return dfastate_36
+ if c.ascii == 38 then return dfastate_36
+ if c.ascii == 39 then return dfastate_36
+ if c.ascii == 40 then return dfastate_36
+ if c.ascii == 41 then return dfastate_36
+ if c.ascii == 42 then return dfastate_36
+ if c.ascii == 43 then return dfastate_36
+ if c.ascii == 44 then return dfastate_36
+ if c.ascii == 45 then return dfastate_36
+ if c.ascii == 46 then return dfastate_36
+ if c.ascii == 47 then return dfastate_36
+ if c.ascii == 48 then return dfastate_36
+ if c.ascii == 49 then return dfastate_36
+ if c.ascii == 50 then return dfastate_36
+ if c.ascii == 51 then return dfastate_36
+ if c.ascii == 52 then return dfastate_36
+ if c.ascii == 53 then return dfastate_36
+ if c.ascii == 54 then return dfastate_36
+ if c.ascii == 55 then return dfastate_36
+ if c.ascii == 56 then return dfastate_36
+ if c.ascii == 57 then return dfastate_36
+ if c.ascii == 58 then return dfastate_36
+ if c.ascii == 59 then return dfastate_36
+ if c.ascii == 60 then return dfastate_36
+ if c.ascii == 61 then return dfastate_36
+ if c.ascii == 62 then return dfastate_36
+ if c.ascii == 63 then return dfastate_36
+ if c.ascii == 64 then return dfastate_36
+ if c.ascii == 65 then return dfastate_36
+ if c.ascii == 66 then return dfastate_36
+ if c.ascii == 67 then return dfastate_36
+ if c.ascii == 68 then return dfastate_36
+ if c.ascii == 69 then return dfastate_36
+ if c.ascii == 70 then return dfastate_36
+ if c.ascii == 71 then return dfastate_36
+ if c.ascii == 72 then return dfastate_36
+ if c.ascii == 73 then return dfastate_36
+ if c.ascii == 74 then return dfastate_36
+ if c.ascii == 75 then return dfastate_36
+ if c.ascii == 76 then return dfastate_36
+ if c.ascii == 77 then return dfastate_36
+ if c.ascii == 78 then return dfastate_36
+ if c.ascii == 79 then return dfastate_36
+ if c.ascii == 80 then return dfastate_36
+ if c.ascii == 81 then return dfastate_36
+ if c.ascii == 82 then return dfastate_36
+ if c.ascii == 83 then return dfastate_36
+ if c.ascii == 84 then return dfastate_36
+ if c.ascii == 85 then return dfastate_36
+ if c.ascii == 86 then return dfastate_36
+ if c.ascii == 87 then return dfastate_36
+ if c.ascii == 88 then return dfastate_36
+ if c.ascii == 89 then return dfastate_36
+ if c.ascii == 90 then return dfastate_36
+ if c.ascii == 91 then return dfastate_36
+ if c.ascii == 92 then return dfastate_41
+ if c.ascii == 93 then return dfastate_36
+ if c.ascii == 94 then return dfastate_36
+ if c.ascii == 95 then return dfastate_36
+ if c.ascii == 96 then return dfastate_36
+ if c.ascii == 97 then return dfastate_36
+ if c.ascii == 98 then return dfastate_36
+ if c.ascii == 99 then return dfastate_36
+ if c.ascii == 100 then return dfastate_36
+ if c.ascii == 101 then return dfastate_36
+ if c.ascii == 102 then return dfastate_36
+ if c.ascii == 103 then return dfastate_36
+ if c.ascii == 104 then return dfastate_36
+ if c.ascii == 105 then return dfastate_36
+ if c.ascii == 106 then return dfastate_36
+ if c.ascii == 107 then return dfastate_36
+ if c.ascii == 108 then return dfastate_36
+ if c.ascii == 109 then return dfastate_36
+ if c.ascii == 110 then return dfastate_36
+ if c.ascii == 111 then return dfastate_36
+ if c.ascii == 112 then return dfastate_36
+ if c.ascii == 113 then return dfastate_36
+ if c.ascii == 114 then return dfastate_36
+ if c.ascii == 115 then return dfastate_36
+ if c.ascii == 116 then return dfastate_36
+ if c.ascii == 117 then return dfastate_36
+ if c.ascii == 118 then return dfastate_36
+ if c.ascii == 119 then return dfastate_36
+ if c.ascii == 120 then return dfastate_36
+ if c.ascii == 121 then return dfastate_36
+ if c.ascii == 122 then return dfastate_36
+ if c.ascii == 123 then return dfastate_36
+ if c.ascii == 124 then return dfastate_36
+ if c.ascii == 125 then return dfastate_36
+ if c.ascii == 126 then return dfastate_36
+ return null
+ end
+end
+class DFAState42
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 34 then return dfastate_35
+ if c.ascii == 32 then return dfastate_33
+ if c.ascii == 33 then return dfastate_33
+ if c.ascii == 35 then return dfastate_33
+ if c.ascii == 36 then return dfastate_33
+ if c.ascii == 37 then return dfastate_33
+ if c.ascii == 38 then return dfastate_33
+ if c.ascii == 39 then return dfastate_33
+ if c.ascii == 40 then return dfastate_33
+ if c.ascii == 41 then return dfastate_33
+ if c.ascii == 42 then return dfastate_33
+ if c.ascii == 43 then return dfastate_33
+ if c.ascii == 44 then return dfastate_33
+ if c.ascii == 45 then return dfastate_33
+ if c.ascii == 46 then return dfastate_33
+ if c.ascii == 47 then return dfastate_33
+ if c.ascii == 48 then return dfastate_33
+ if c.ascii == 49 then return dfastate_33
+ if c.ascii == 50 then return dfastate_33
+ if c.ascii == 51 then return dfastate_33
+ if c.ascii == 52 then return dfastate_33
+ if c.ascii == 53 then return dfastate_33
+ if c.ascii == 54 then return dfastate_33
+ if c.ascii == 55 then return dfastate_33
+ if c.ascii == 56 then return dfastate_33
+ if c.ascii == 57 then return dfastate_33
+ if c.ascii == 58 then return dfastate_33
+ if c.ascii == 59 then return dfastate_33
+ if c.ascii == 60 then return dfastate_33
+ if c.ascii == 61 then return dfastate_33
+ if c.ascii == 62 then return dfastate_33
+ if c.ascii == 63 then return dfastate_33
+ if c.ascii == 64 then return dfastate_33
+ if c.ascii == 65 then return dfastate_33
+ if c.ascii == 66 then return dfastate_33
+ if c.ascii == 67 then return dfastate_33
+ if c.ascii == 68 then return dfastate_33
+ if c.ascii == 69 then return dfastate_33
+ if c.ascii == 70 then return dfastate_33
+ if c.ascii == 71 then return dfastate_33
+ if c.ascii == 72 then return dfastate_33
+ if c.ascii == 73 then return dfastate_33
+ if c.ascii == 74 then return dfastate_33
+ if c.ascii == 75 then return dfastate_33
+ if c.ascii == 76 then return dfastate_33
+ if c.ascii == 77 then return dfastate_33
+ if c.ascii == 78 then return dfastate_33
+ if c.ascii == 79 then return dfastate_33
+ if c.ascii == 80 then return dfastate_33
+ if c.ascii == 81 then return dfastate_33
+ if c.ascii == 82 then return dfastate_33
+ if c.ascii == 83 then return dfastate_33
+ if c.ascii == 84 then return dfastate_33
+ if c.ascii == 85 then return dfastate_33
+ if c.ascii == 86 then return dfastate_33
+ if c.ascii == 87 then return dfastate_33
+ if c.ascii == 88 then return dfastate_33
+ if c.ascii == 89 then return dfastate_33
+ if c.ascii == 90 then return dfastate_33
+ if c.ascii == 91 then return dfastate_33
+ if c.ascii == 92 then return dfastate_39
+ if c.ascii == 93 then return dfastate_33
+ if c.ascii == 94 then return dfastate_33
+ if c.ascii == 95 then return dfastate_33
+ if c.ascii == 96 then return dfastate_33
+ if c.ascii == 97 then return dfastate_33
+ if c.ascii == 98 then return dfastate_33
+ if c.ascii == 99 then return dfastate_33
+ if c.ascii == 100 then return dfastate_33
+ if c.ascii == 101 then return dfastate_33
+ if c.ascii == 102 then return dfastate_33
+ if c.ascii == 103 then return dfastate_33
+ if c.ascii == 104 then return dfastate_33
+ if c.ascii == 105 then return dfastate_33
+ if c.ascii == 106 then return dfastate_33
+ if c.ascii == 107 then return dfastate_33
+ if c.ascii == 108 then return dfastate_33
+ if c.ascii == 109 then return dfastate_33
+ if c.ascii == 110 then return dfastate_33
+ if c.ascii == 111 then return dfastate_33
+ if c.ascii == 112 then return dfastate_33
+ if c.ascii == 113 then return dfastate_33
+ if c.ascii == 114 then return dfastate_33
+ if c.ascii == 115 then return dfastate_33
+ if c.ascii == 116 then return dfastate_33
+ if c.ascii == 117 then return dfastate_33
+ if c.ascii == 118 then return dfastate_33
+ if c.ascii == 119 then return dfastate_33
+ if c.ascii == 120 then return dfastate_33
+ if c.ascii == 121 then return dfastate_33
+ if c.ascii == 122 then return dfastate_33
+ if c.ascii == 123 then return dfastate_33
+ if c.ascii == 124 then return dfastate_33
+ if c.ascii == 125 then return dfastate_33
+ if c.ascii == 126 then return dfastate_33
+ return null
+ end
+end
+class DFAState43
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 113 then return dfastate_95
+ if c.ascii == 81 then return dfastate_96
+ if c.ascii == 110 then return dfastate_97
+ if c.ascii == 78 then return dfastate_98
+ return null
+ end
+end
+class DFAState44
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 113 then return dfastate_95
+ if c.ascii == 81 then return dfastate_96
+ if c.ascii == 110 then return dfastate_97
+ if c.ascii == 78 then return dfastate_98
+ return null
+ end
+end
+class DFAState45
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 117 then return dfastate_75
+ if c.ascii == 85 then return dfastate_76
+ if c.ascii == 108 then return dfastate_77
+ if c.ascii == 76 then return dfastate_78
+ if c.ascii == 121 then return dfastate_79
+ if c.ascii == 89 then return dfastate_80
+ return null
+ end
+end
+class DFAState46
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 117 then return dfastate_75
+ if c.ascii == 85 then return dfastate_76
+ if c.ascii == 108 then return dfastate_77
+ if c.ascii == 76 then return dfastate_78
+ if c.ascii == 121 then return dfastate_79
+ if c.ascii == 89 then return dfastate_80
+ return null
+ end
+end
+class DFAState47
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 111 then return dfastate_69
+ if c.ascii == 79 then return dfastate_70
+ return null
+ end
+end
+class DFAState48
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 111 then return dfastate_69
+ if c.ascii == 79 then return dfastate_70
+ return null
+ end
+end
+class DFAState49
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 100 then return dfastate_51
+ if c.ascii == 68 then return dfastate_52
+ if c.ascii == 115 then return dfastate_53
+ if c.ascii == 83 then return dfastate_54
+ return null
+ end
+end
+class DFAState50
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 100 then return dfastate_51
+ if c.ascii == 68 then return dfastate_52
+ if c.ascii == 115 then return dfastate_53
+ if c.ascii == 83 then return dfastate_54
+ return null
+ end
+end
+class DFAState51
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 100 then return dfastate_61
+ if c.ascii == 68 then return dfastate_62
+ return null
+ end
+end
+class DFAState52
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 100 then return dfastate_61
+ if c.ascii == 68 then return dfastate_62
+ return null
+ end
+end
+class DFAState53
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 99 then return dfastate_55
+ if c.ascii == 67 then return dfastate_56
+ return null
+ end
+end
+class DFAState54
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 99 then return dfastate_55
+ if c.ascii == 67 then return dfastate_56
+ return null
+ end
+end
+class DFAState55
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 105 then return dfastate_57
+ if c.ascii == 73 then return dfastate_58
+ return null
+ end
+end
+class DFAState56
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 105 then return dfastate_57
+ if c.ascii == 73 then return dfastate_58
+ return null
+ end
+end
+class DFAState57
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 105 then return dfastate_59
+ if c.ascii == 73 then return dfastate_60
+ return null
+ end
+end
+class DFAState58
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 105 then return dfastate_59
+ if c.ascii == 73 then return dfastate_60
+ return null
+ end
+end
+class DFAState59
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_ascii
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState60
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_ascii
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState61
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 114 then return dfastate_63
+ if c.ascii == 82 then return dfastate_64
+ return null
+ end
+end
+class DFAState62
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 114 then return dfastate_63
+ if c.ascii == 82 then return dfastate_64
+ return null
+ end
+end
+class DFAState63
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 115 then return dfastate_65
+ if c.ascii == 83 then return dfastate_66
+ return null
+ end
+end
+class DFAState64
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 115 then return dfastate_65
+ if c.ascii == 83 then return dfastate_66
+ return null
+ end
+end
+class DFAState65
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 115 then return dfastate_67
+ if c.ascii == 83 then return dfastate_68
+ return null
+ end
+end
+class DFAState66
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 115 then return dfastate_67
+ if c.ascii == 83 then return dfastate_68
+ return null
+ end
+end
+class DFAState67
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_addrss
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState68
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_addrss
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState69
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 114 then return dfastate_71
+ if c.ascii == 82 then return dfastate_72
+ return null
+ end
+end
+class DFAState70
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 114 then return dfastate_71
+ if c.ascii == 82 then return dfastate_72
+ return null
+ end
+end
+class DFAState71
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 100 then return dfastate_73
+ if c.ascii == 68 then return dfastate_74
+ return null
+ end
+end
+class DFAState72
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 100 then return dfastate_73
+ if c.ascii == 68 then return dfastate_74
+ return null
+ end
+end
+class DFAState73
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_word
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState74
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_word
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState75
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 114 then return dfastate_91
+ if c.ascii == 82 then return dfastate_92
+ return null
+ end
+end
+class DFAState76
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 114 then return dfastate_91
+ if c.ascii == 82 then return dfastate_92
+ return null
+ end
+end
+class DFAState77
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 111 then return dfastate_85
+ if c.ascii == 79 then return dfastate_86
+ return null
+ end
+end
+class DFAState78
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 111 then return dfastate_85
+ if c.ascii == 79 then return dfastate_86
+ return null
+ end
+end
+class DFAState79
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 116 then return dfastate_81
+ if c.ascii == 84 then return dfastate_82
+ return null
+ end
+end
+class DFAState80
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 116 then return dfastate_81
+ if c.ascii == 84 then return dfastate_82
+ return null
+ end
+end
+class DFAState81
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 101 then return dfastate_83
+ if c.ascii == 69 then return dfastate_84
+ return null
+ end
+end
+class DFAState82
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 101 then return dfastate_83
+ if c.ascii == 69 then return dfastate_84
+ return null
+ end
+end
+class DFAState83
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_byte
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState84
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_byte
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState85
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 99 then return dfastate_87
+ if c.ascii == 67 then return dfastate_88
+ return null
+ end
+end
+class DFAState86
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 99 then return dfastate_87
+ if c.ascii == 67 then return dfastate_88
+ return null
+ end
+end
+class DFAState87
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 107 then return dfastate_89
+ if c.ascii == 75 then return dfastate_90
+ return null
+ end
+end
+class DFAState88
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 107 then return dfastate_89
+ if c.ascii == 75 then return dfastate_90
+ return null
+ end
+end
+class DFAState89
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_block
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState90
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_block
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState91
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 110 then return dfastate_93
+ if c.ascii == 78 then return dfastate_94
+ return null
+ end
+end
+class DFAState92
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 110 then return dfastate_93
+ if c.ascii == 78 then return dfastate_94
+ return null
+ end
+end
+class DFAState93
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_burn
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState94
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_burn
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState95
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 117 then return dfastate_105
+ if c.ascii == 85 then return dfastate_106
+ return null
+ end
+end
+class DFAState96
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 117 then return dfastate_105
+ if c.ascii == 85 then return dfastate_106
+ return null
+ end
+end
+class DFAState97
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 100 then return dfastate_99
+ if c.ascii == 68 then return dfastate_100
+ return null
+ end
+end
+class DFAState98
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 100 then return dfastate_99
+ if c.ascii == 68 then return dfastate_100
+ return null
+ end
+end
+class DFAState99
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nend_block
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_101
+ if c.ascii == 33 then return dfastate_101
+ if c.ascii == 34 then return dfastate_101
+ if c.ascii == 35 then return dfastate_101
+ if c.ascii == 36 then return dfastate_101
+ if c.ascii == 37 then return dfastate_101
+ if c.ascii == 38 then return dfastate_101
+ if c.ascii == 39 then return dfastate_101
+ if c.ascii == 40 then return dfastate_101
+ if c.ascii == 41 then return dfastate_101
+ if c.ascii == 42 then return dfastate_101
+ if c.ascii == 43 then return dfastate_101
+ if c.ascii == 44 then return dfastate_101
+ if c.ascii == 45 then return dfastate_101
+ if c.ascii == 46 then return dfastate_101
+ if c.ascii == 47 then return dfastate_101
+ if c.ascii == 48 then return dfastate_101
+ if c.ascii == 49 then return dfastate_101
+ if c.ascii == 50 then return dfastate_101
+ if c.ascii == 51 then return dfastate_101
+ if c.ascii == 52 then return dfastate_101
+ if c.ascii == 53 then return dfastate_101
+ if c.ascii == 54 then return dfastate_101
+ if c.ascii == 55 then return dfastate_101
+ if c.ascii == 56 then return dfastate_101
+ if c.ascii == 57 then return dfastate_101
+ if c.ascii == 58 then return dfastate_101
+ if c.ascii == 59 then return dfastate_101
+ if c.ascii == 60 then return dfastate_101
+ if c.ascii == 61 then return dfastate_101
+ if c.ascii == 62 then return dfastate_101
+ if c.ascii == 63 then return dfastate_101
+ if c.ascii == 64 then return dfastate_101
+ if c.ascii == 65 then return dfastate_101
+ if c.ascii == 66 then return dfastate_101
+ if c.ascii == 67 then return dfastate_101
+ if c.ascii == 68 then return dfastate_101
+ if c.ascii == 69 then return dfastate_101
+ if c.ascii == 70 then return dfastate_101
+ if c.ascii == 71 then return dfastate_101
+ if c.ascii == 72 then return dfastate_101
+ if c.ascii == 73 then return dfastate_101
+ if c.ascii == 74 then return dfastate_101
+ if c.ascii == 75 then return dfastate_101
+ if c.ascii == 76 then return dfastate_101
+ if c.ascii == 77 then return dfastate_101
+ if c.ascii == 78 then return dfastate_101
+ if c.ascii == 79 then return dfastate_101
+ if c.ascii == 80 then return dfastate_101
+ if c.ascii == 81 then return dfastate_101
+ if c.ascii == 82 then return dfastate_101
+ if c.ascii == 83 then return dfastate_101
+ if c.ascii == 84 then return dfastate_101
+ if c.ascii == 85 then return dfastate_101
+ if c.ascii == 86 then return dfastate_101
+ if c.ascii == 87 then return dfastate_101
+ if c.ascii == 88 then return dfastate_101
+ if c.ascii == 89 then return dfastate_101
+ if c.ascii == 90 then return dfastate_101
+ if c.ascii == 91 then return dfastate_101
+ if c.ascii == 92 then return dfastate_101
+ if c.ascii == 93 then return dfastate_101
+ if c.ascii == 94 then return dfastate_101
+ if c.ascii == 95 then return dfastate_101
+ if c.ascii == 96 then return dfastate_101
+ if c.ascii == 97 then return dfastate_101
+ if c.ascii == 98 then return dfastate_101
+ if c.ascii == 99 then return dfastate_101
+ if c.ascii == 100 then return dfastate_101
+ if c.ascii == 101 then return dfastate_101
+ if c.ascii == 102 then return dfastate_101
+ if c.ascii == 103 then return dfastate_101
+ if c.ascii == 104 then return dfastate_101
+ if c.ascii == 105 then return dfastate_101
+ if c.ascii == 106 then return dfastate_101
+ if c.ascii == 107 then return dfastate_101
+ if c.ascii == 108 then return dfastate_101
+ if c.ascii == 109 then return dfastate_101
+ if c.ascii == 110 then return dfastate_101
+ if c.ascii == 111 then return dfastate_101
+ if c.ascii == 112 then return dfastate_101
+ if c.ascii == 113 then return dfastate_101
+ if c.ascii == 114 then return dfastate_101
+ if c.ascii == 115 then return dfastate_101
+ if c.ascii == 116 then return dfastate_101
+ if c.ascii == 117 then return dfastate_101
+ if c.ascii == 118 then return dfastate_101
+ if c.ascii == 119 then return dfastate_101
+ if c.ascii == 120 then return dfastate_101
+ if c.ascii == 121 then return dfastate_101
+ if c.ascii == 122 then return dfastate_101
+ if c.ascii == 123 then return dfastate_101
+ if c.ascii == 124 then return dfastate_101
+ if c.ascii == 125 then return dfastate_101
+ if c.ascii == 126 then return dfastate_101
+ if c.ascii == 13 then return dfastate_102
+ if c.ascii == 10 then return dfastate_103
+ return null
+ end
+end
+class DFAState100
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nend_block
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_101
+ if c.ascii == 33 then return dfastate_101
+ if c.ascii == 34 then return dfastate_101
+ if c.ascii == 35 then return dfastate_101
+ if c.ascii == 36 then return dfastate_101
+ if c.ascii == 37 then return dfastate_101
+ if c.ascii == 38 then return dfastate_101
+ if c.ascii == 39 then return dfastate_101
+ if c.ascii == 40 then return dfastate_101
+ if c.ascii == 41 then return dfastate_101
+ if c.ascii == 42 then return dfastate_101
+ if c.ascii == 43 then return dfastate_101
+ if c.ascii == 44 then return dfastate_101
+ if c.ascii == 45 then return dfastate_101
+ if c.ascii == 46 then return dfastate_101
+ if c.ascii == 47 then return dfastate_101
+ if c.ascii == 48 then return dfastate_101
+ if c.ascii == 49 then return dfastate_101
+ if c.ascii == 50 then return dfastate_101
+ if c.ascii == 51 then return dfastate_101
+ if c.ascii == 52 then return dfastate_101
+ if c.ascii == 53 then return dfastate_101
+ if c.ascii == 54 then return dfastate_101
+ if c.ascii == 55 then return dfastate_101
+ if c.ascii == 56 then return dfastate_101
+ if c.ascii == 57 then return dfastate_101
+ if c.ascii == 58 then return dfastate_101
+ if c.ascii == 59 then return dfastate_101
+ if c.ascii == 60 then return dfastate_101
+ if c.ascii == 61 then return dfastate_101
+ if c.ascii == 62 then return dfastate_101
+ if c.ascii == 63 then return dfastate_101
+ if c.ascii == 64 then return dfastate_101
+ if c.ascii == 65 then return dfastate_101
+ if c.ascii == 66 then return dfastate_101
+ if c.ascii == 67 then return dfastate_101
+ if c.ascii == 68 then return dfastate_101
+ if c.ascii == 69 then return dfastate_101
+ if c.ascii == 70 then return dfastate_101
+ if c.ascii == 71 then return dfastate_101
+ if c.ascii == 72 then return dfastate_101
+ if c.ascii == 73 then return dfastate_101
+ if c.ascii == 74 then return dfastate_101
+ if c.ascii == 75 then return dfastate_101
+ if c.ascii == 76 then return dfastate_101
+ if c.ascii == 77 then return dfastate_101
+ if c.ascii == 78 then return dfastate_101
+ if c.ascii == 79 then return dfastate_101
+ if c.ascii == 80 then return dfastate_101
+ if c.ascii == 81 then return dfastate_101
+ if c.ascii == 82 then return dfastate_101
+ if c.ascii == 83 then return dfastate_101
+ if c.ascii == 84 then return dfastate_101
+ if c.ascii == 85 then return dfastate_101
+ if c.ascii == 86 then return dfastate_101
+ if c.ascii == 87 then return dfastate_101
+ if c.ascii == 88 then return dfastate_101
+ if c.ascii == 89 then return dfastate_101
+ if c.ascii == 90 then return dfastate_101
+ if c.ascii == 91 then return dfastate_101
+ if c.ascii == 92 then return dfastate_101
+ if c.ascii == 93 then return dfastate_101
+ if c.ascii == 94 then return dfastate_101
+ if c.ascii == 95 then return dfastate_101
+ if c.ascii == 96 then return dfastate_101
+ if c.ascii == 97 then return dfastate_101
+ if c.ascii == 98 then return dfastate_101
+ if c.ascii == 99 then return dfastate_101
+ if c.ascii == 100 then return dfastate_101
+ if c.ascii == 101 then return dfastate_101
+ if c.ascii == 102 then return dfastate_101
+ if c.ascii == 103 then return dfastate_101
+ if c.ascii == 104 then return dfastate_101
+ if c.ascii == 105 then return dfastate_101
+ if c.ascii == 106 then return dfastate_101
+ if c.ascii == 107 then return dfastate_101
+ if c.ascii == 108 then return dfastate_101
+ if c.ascii == 109 then return dfastate_101
+ if c.ascii == 110 then return dfastate_101
+ if c.ascii == 111 then return dfastate_101
+ if c.ascii == 112 then return dfastate_101
+ if c.ascii == 113 then return dfastate_101
+ if c.ascii == 114 then return dfastate_101
+ if c.ascii == 115 then return dfastate_101
+ if c.ascii == 116 then return dfastate_101
+ if c.ascii == 117 then return dfastate_101
+ if c.ascii == 118 then return dfastate_101
+ if c.ascii == 119 then return dfastate_101
+ if c.ascii == 120 then return dfastate_101
+ if c.ascii == 121 then return dfastate_101
+ if c.ascii == 122 then return dfastate_101
+ if c.ascii == 123 then return dfastate_101
+ if c.ascii == 124 then return dfastate_101
+ if c.ascii == 125 then return dfastate_101
+ if c.ascii == 126 then return dfastate_101
+ if c.ascii == 13 then return dfastate_102
+ if c.ascii == 10 then return dfastate_103
+ return null
+ end
+end
+class DFAState101
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nend_block
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_101
+ if c.ascii == 33 then return dfastate_101
+ if c.ascii == 34 then return dfastate_101
+ if c.ascii == 35 then return dfastate_101
+ if c.ascii == 36 then return dfastate_101
+ if c.ascii == 37 then return dfastate_101
+ if c.ascii == 38 then return dfastate_101
+ if c.ascii == 39 then return dfastate_101
+ if c.ascii == 40 then return dfastate_101
+ if c.ascii == 41 then return dfastate_101
+ if c.ascii == 42 then return dfastate_101
+ if c.ascii == 43 then return dfastate_101
+ if c.ascii == 44 then return dfastate_101
+ if c.ascii == 45 then return dfastate_101
+ if c.ascii == 46 then return dfastate_101
+ if c.ascii == 47 then return dfastate_101
+ if c.ascii == 48 then return dfastate_101
+ if c.ascii == 49 then return dfastate_101
+ if c.ascii == 50 then return dfastate_101
+ if c.ascii == 51 then return dfastate_101
+ if c.ascii == 52 then return dfastate_101
+ if c.ascii == 53 then return dfastate_101
+ if c.ascii == 54 then return dfastate_101
+ if c.ascii == 55 then return dfastate_101
+ if c.ascii == 56 then return dfastate_101
+ if c.ascii == 57 then return dfastate_101
+ if c.ascii == 58 then return dfastate_101
+ if c.ascii == 59 then return dfastate_101
+ if c.ascii == 60 then return dfastate_101
+ if c.ascii == 61 then return dfastate_101
+ if c.ascii == 62 then return dfastate_101
+ if c.ascii == 63 then return dfastate_101
+ if c.ascii == 64 then return dfastate_101
+ if c.ascii == 65 then return dfastate_101
+ if c.ascii == 66 then return dfastate_101
+ if c.ascii == 67 then return dfastate_101
+ if c.ascii == 68 then return dfastate_101
+ if c.ascii == 69 then return dfastate_101
+ if c.ascii == 70 then return dfastate_101
+ if c.ascii == 71 then return dfastate_101
+ if c.ascii == 72 then return dfastate_101
+ if c.ascii == 73 then return dfastate_101
+ if c.ascii == 74 then return dfastate_101
+ if c.ascii == 75 then return dfastate_101
+ if c.ascii == 76 then return dfastate_101
+ if c.ascii == 77 then return dfastate_101
+ if c.ascii == 78 then return dfastate_101
+ if c.ascii == 79 then return dfastate_101
+ if c.ascii == 80 then return dfastate_101
+ if c.ascii == 81 then return dfastate_101
+ if c.ascii == 82 then return dfastate_101
+ if c.ascii == 83 then return dfastate_101
+ if c.ascii == 84 then return dfastate_101
+ if c.ascii == 85 then return dfastate_101
+ if c.ascii == 86 then return dfastate_101
+ if c.ascii == 87 then return dfastate_101
+ if c.ascii == 88 then return dfastate_101
+ if c.ascii == 89 then return dfastate_101
+ if c.ascii == 90 then return dfastate_101
+ if c.ascii == 91 then return dfastate_101
+ if c.ascii == 92 then return dfastate_101
+ if c.ascii == 93 then return dfastate_101
+ if c.ascii == 94 then return dfastate_101
+ if c.ascii == 95 then return dfastate_101
+ if c.ascii == 96 then return dfastate_101
+ if c.ascii == 97 then return dfastate_101
+ if c.ascii == 98 then return dfastate_101
+ if c.ascii == 99 then return dfastate_101
+ if c.ascii == 100 then return dfastate_101
+ if c.ascii == 101 then return dfastate_101
+ if c.ascii == 102 then return dfastate_101
+ if c.ascii == 103 then return dfastate_101
+ if c.ascii == 104 then return dfastate_101
+ if c.ascii == 105 then return dfastate_101
+ if c.ascii == 106 then return dfastate_101
+ if c.ascii == 107 then return dfastate_101
+ if c.ascii == 108 then return dfastate_101
+ if c.ascii == 109 then return dfastate_101
+ if c.ascii == 110 then return dfastate_101
+ if c.ascii == 111 then return dfastate_101
+ if c.ascii == 112 then return dfastate_101
+ if c.ascii == 113 then return dfastate_101
+ if c.ascii == 114 then return dfastate_101
+ if c.ascii == 115 then return dfastate_101
+ if c.ascii == 116 then return dfastate_101
+ if c.ascii == 117 then return dfastate_101
+ if c.ascii == 118 then return dfastate_101
+ if c.ascii == 119 then return dfastate_101
+ if c.ascii == 120 then return dfastate_101
+ if c.ascii == 121 then return dfastate_101
+ if c.ascii == 122 then return dfastate_101
+ if c.ascii == 123 then return dfastate_101
+ if c.ascii == 124 then return dfastate_101
+ if c.ascii == 125 then return dfastate_101
+ if c.ascii == 126 then return dfastate_101
+ if c.ascii == 13 then return dfastate_102
+ if c.ascii == 10 then return dfastate_103
+ return null
+ end
+end
+class DFAState102
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nend_block
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_101
+ if c.ascii == 33 then return dfastate_101
+ if c.ascii == 34 then return dfastate_101
+ if c.ascii == 35 then return dfastate_101
+ if c.ascii == 36 then return dfastate_101
+ if c.ascii == 37 then return dfastate_101
+ if c.ascii == 38 then return dfastate_101
+ if c.ascii == 39 then return dfastate_101
+ if c.ascii == 40 then return dfastate_101
+ if c.ascii == 41 then return dfastate_101
+ if c.ascii == 42 then return dfastate_101
+ if c.ascii == 43 then return dfastate_101
+ if c.ascii == 44 then return dfastate_101
+ if c.ascii == 45 then return dfastate_101
+ if c.ascii == 46 then return dfastate_101
+ if c.ascii == 47 then return dfastate_101
+ if c.ascii == 48 then return dfastate_101
+ if c.ascii == 49 then return dfastate_101
+ if c.ascii == 50 then return dfastate_101
+ if c.ascii == 51 then return dfastate_101
+ if c.ascii == 52 then return dfastate_101
+ if c.ascii == 53 then return dfastate_101
+ if c.ascii == 54 then return dfastate_101
+ if c.ascii == 55 then return dfastate_101
+ if c.ascii == 56 then return dfastate_101
+ if c.ascii == 57 then return dfastate_101
+ if c.ascii == 58 then return dfastate_101
+ if c.ascii == 59 then return dfastate_101
+ if c.ascii == 60 then return dfastate_101
+ if c.ascii == 61 then return dfastate_101
+ if c.ascii == 62 then return dfastate_101
+ if c.ascii == 63 then return dfastate_101
+ if c.ascii == 64 then return dfastate_101
+ if c.ascii == 65 then return dfastate_101
+ if c.ascii == 66 then return dfastate_101
+ if c.ascii == 67 then return dfastate_101
+ if c.ascii == 68 then return dfastate_101
+ if c.ascii == 69 then return dfastate_101
+ if c.ascii == 70 then return dfastate_101
+ if c.ascii == 71 then return dfastate_101
+ if c.ascii == 72 then return dfastate_101
+ if c.ascii == 73 then return dfastate_101
+ if c.ascii == 74 then return dfastate_101
+ if c.ascii == 75 then return dfastate_101
+ if c.ascii == 76 then return dfastate_101
+ if c.ascii == 77 then return dfastate_101
+ if c.ascii == 78 then return dfastate_101
+ if c.ascii == 79 then return dfastate_101
+ if c.ascii == 80 then return dfastate_101
+ if c.ascii == 81 then return dfastate_101
+ if c.ascii == 82 then return dfastate_101
+ if c.ascii == 83 then return dfastate_101
+ if c.ascii == 84 then return dfastate_101
+ if c.ascii == 85 then return dfastate_101
+ if c.ascii == 86 then return dfastate_101
+ if c.ascii == 87 then return dfastate_101
+ if c.ascii == 88 then return dfastate_101
+ if c.ascii == 89 then return dfastate_101
+ if c.ascii == 90 then return dfastate_101
+ if c.ascii == 91 then return dfastate_101
+ if c.ascii == 92 then return dfastate_101
+ if c.ascii == 93 then return dfastate_101
+ if c.ascii == 94 then return dfastate_101
+ if c.ascii == 95 then return dfastate_101
+ if c.ascii == 96 then return dfastate_101
+ if c.ascii == 97 then return dfastate_101
+ if c.ascii == 98 then return dfastate_101
+ if c.ascii == 99 then return dfastate_101
+ if c.ascii == 100 then return dfastate_101
+ if c.ascii == 101 then return dfastate_101
+ if c.ascii == 102 then return dfastate_101
+ if c.ascii == 103 then return dfastate_101
+ if c.ascii == 104 then return dfastate_101
+ if c.ascii == 105 then return dfastate_101
+ if c.ascii == 106 then return dfastate_101
+ if c.ascii == 107 then return dfastate_101
+ if c.ascii == 108 then return dfastate_101
+ if c.ascii == 109 then return dfastate_101
+ if c.ascii == 110 then return dfastate_101
+ if c.ascii == 111 then return dfastate_101
+ if c.ascii == 112 then return dfastate_101
+ if c.ascii == 113 then return dfastate_101
+ if c.ascii == 114 then return dfastate_101
+ if c.ascii == 115 then return dfastate_101
+ if c.ascii == 116 then return dfastate_101
+ if c.ascii == 117 then return dfastate_101
+ if c.ascii == 118 then return dfastate_101
+ if c.ascii == 119 then return dfastate_101
+ if c.ascii == 120 then return dfastate_101
+ if c.ascii == 121 then return dfastate_101
+ if c.ascii == 122 then return dfastate_101
+ if c.ascii == 123 then return dfastate_101
+ if c.ascii == 124 then return dfastate_101
+ if c.ascii == 125 then return dfastate_101
+ if c.ascii == 126 then return dfastate_101
+ if c.ascii == 13 then return dfastate_102
+ if c.ascii == 10 then return dfastate_103
+ return null
+ end
+end
+class DFAState103
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nend_block
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 13 then return dfastate_104
+ if c.ascii == 32 then return dfastate_101
+ if c.ascii == 33 then return dfastate_101
+ if c.ascii == 34 then return dfastate_101
+ if c.ascii == 35 then return dfastate_101
+ if c.ascii == 36 then return dfastate_101
+ if c.ascii == 37 then return dfastate_101
+ if c.ascii == 38 then return dfastate_101
+ if c.ascii == 39 then return dfastate_101
+ if c.ascii == 40 then return dfastate_101
+ if c.ascii == 41 then return dfastate_101
+ if c.ascii == 42 then return dfastate_101
+ if c.ascii == 43 then return dfastate_101
+ if c.ascii == 44 then return dfastate_101
+ if c.ascii == 45 then return dfastate_101
+ if c.ascii == 46 then return dfastate_101
+ if c.ascii == 47 then return dfastate_101
+ if c.ascii == 48 then return dfastate_101
+ if c.ascii == 49 then return dfastate_101
+ if c.ascii == 50 then return dfastate_101
+ if c.ascii == 51 then return dfastate_101
+ if c.ascii == 52 then return dfastate_101
+ if c.ascii == 53 then return dfastate_101
+ if c.ascii == 54 then return dfastate_101
+ if c.ascii == 55 then return dfastate_101
+ if c.ascii == 56 then return dfastate_101
+ if c.ascii == 57 then return dfastate_101
+ if c.ascii == 58 then return dfastate_101
+ if c.ascii == 59 then return dfastate_101
+ if c.ascii == 60 then return dfastate_101
+ if c.ascii == 61 then return dfastate_101
+ if c.ascii == 62 then return dfastate_101
+ if c.ascii == 63 then return dfastate_101
+ if c.ascii == 64 then return dfastate_101
+ if c.ascii == 65 then return dfastate_101
+ if c.ascii == 66 then return dfastate_101
+ if c.ascii == 67 then return dfastate_101
+ if c.ascii == 68 then return dfastate_101
+ if c.ascii == 69 then return dfastate_101
+ if c.ascii == 70 then return dfastate_101
+ if c.ascii == 71 then return dfastate_101
+ if c.ascii == 72 then return dfastate_101
+ if c.ascii == 73 then return dfastate_101
+ if c.ascii == 74 then return dfastate_101
+ if c.ascii == 75 then return dfastate_101
+ if c.ascii == 76 then return dfastate_101
+ if c.ascii == 77 then return dfastate_101
+ if c.ascii == 78 then return dfastate_101
+ if c.ascii == 79 then return dfastate_101
+ if c.ascii == 80 then return dfastate_101
+ if c.ascii == 81 then return dfastate_101
+ if c.ascii == 82 then return dfastate_101
+ if c.ascii == 83 then return dfastate_101
+ if c.ascii == 84 then return dfastate_101
+ if c.ascii == 85 then return dfastate_101
+ if c.ascii == 86 then return dfastate_101
+ if c.ascii == 87 then return dfastate_101
+ if c.ascii == 88 then return dfastate_101
+ if c.ascii == 89 then return dfastate_101
+ if c.ascii == 90 then return dfastate_101
+ if c.ascii == 91 then return dfastate_101
+ if c.ascii == 92 then return dfastate_101
+ if c.ascii == 93 then return dfastate_101
+ if c.ascii == 94 then return dfastate_101
+ if c.ascii == 95 then return dfastate_101
+ if c.ascii == 96 then return dfastate_101
+ if c.ascii == 97 then return dfastate_101
+ if c.ascii == 98 then return dfastate_101
+ if c.ascii == 99 then return dfastate_101
+ if c.ascii == 100 then return dfastate_101
+ if c.ascii == 101 then return dfastate_101
+ if c.ascii == 102 then return dfastate_101
+ if c.ascii == 103 then return dfastate_101
+ if c.ascii == 104 then return dfastate_101
+ if c.ascii == 105 then return dfastate_101
+ if c.ascii == 106 then return dfastate_101
+ if c.ascii == 107 then return dfastate_101
+ if c.ascii == 108 then return dfastate_101
+ if c.ascii == 109 then return dfastate_101
+ if c.ascii == 110 then return dfastate_101
+ if c.ascii == 111 then return dfastate_101
+ if c.ascii == 112 then return dfastate_101
+ if c.ascii == 113 then return dfastate_101
+ if c.ascii == 114 then return dfastate_101
+ if c.ascii == 115 then return dfastate_101
+ if c.ascii == 116 then return dfastate_101
+ if c.ascii == 117 then return dfastate_101
+ if c.ascii == 118 then return dfastate_101
+ if c.ascii == 119 then return dfastate_101
+ if c.ascii == 120 then return dfastate_101
+ if c.ascii == 121 then return dfastate_101
+ if c.ascii == 122 then return dfastate_101
+ if c.ascii == 123 then return dfastate_101
+ if c.ascii == 124 then return dfastate_101
+ if c.ascii == 125 then return dfastate_101
+ if c.ascii == 126 then return dfastate_101
+ if c.ascii == 10 then return dfastate_103
+ return null
+ end
+end
+class DFAState104
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Nend_block
+ t.position = position
+ t.text = text
+ return t
+ end
+ redef fun trans(c) do
+ if c.ascii == 32 then return dfastate_101
+ if c.ascii == 33 then return dfastate_101
+ if c.ascii == 34 then return dfastate_101
+ if c.ascii == 35 then return dfastate_101
+ if c.ascii == 36 then return dfastate_101
+ if c.ascii == 37 then return dfastate_101
+ if c.ascii == 38 then return dfastate_101
+ if c.ascii == 39 then return dfastate_101
+ if c.ascii == 40 then return dfastate_101
+ if c.ascii == 41 then return dfastate_101
+ if c.ascii == 42 then return dfastate_101
+ if c.ascii == 43 then return dfastate_101
+ if c.ascii == 44 then return dfastate_101
+ if c.ascii == 45 then return dfastate_101
+ if c.ascii == 46 then return dfastate_101
+ if c.ascii == 47 then return dfastate_101
+ if c.ascii == 48 then return dfastate_101
+ if c.ascii == 49 then return dfastate_101
+ if c.ascii == 50 then return dfastate_101
+ if c.ascii == 51 then return dfastate_101
+ if c.ascii == 52 then return dfastate_101
+ if c.ascii == 53 then return dfastate_101
+ if c.ascii == 54 then return dfastate_101
+ if c.ascii == 55 then return dfastate_101
+ if c.ascii == 56 then return dfastate_101
+ if c.ascii == 57 then return dfastate_101
+ if c.ascii == 58 then return dfastate_101
+ if c.ascii == 59 then return dfastate_101
+ if c.ascii == 60 then return dfastate_101
+ if c.ascii == 61 then return dfastate_101
+ if c.ascii == 62 then return dfastate_101
+ if c.ascii == 63 then return dfastate_101
+ if c.ascii == 64 then return dfastate_101
+ if c.ascii == 65 then return dfastate_101
+ if c.ascii == 66 then return dfastate_101
+ if c.ascii == 67 then return dfastate_101
+ if c.ascii == 68 then return dfastate_101
+ if c.ascii == 69 then return dfastate_101
+ if c.ascii == 70 then return dfastate_101
+ if c.ascii == 71 then return dfastate_101
+ if c.ascii == 72 then return dfastate_101
+ if c.ascii == 73 then return dfastate_101
+ if c.ascii == 74 then return dfastate_101
+ if c.ascii == 75 then return dfastate_101
+ if c.ascii == 76 then return dfastate_101
+ if c.ascii == 77 then return dfastate_101
+ if c.ascii == 78 then return dfastate_101
+ if c.ascii == 79 then return dfastate_101
+ if c.ascii == 80 then return dfastate_101
+ if c.ascii == 81 then return dfastate_101
+ if c.ascii == 82 then return dfastate_101
+ if c.ascii == 83 then return dfastate_101
+ if c.ascii == 84 then return dfastate_101
+ if c.ascii == 85 then return dfastate_101
+ if c.ascii == 86 then return dfastate_101
+ if c.ascii == 87 then return dfastate_101
+ if c.ascii == 88 then return dfastate_101
+ if c.ascii == 89 then return dfastate_101
+ if c.ascii == 90 then return dfastate_101
+ if c.ascii == 91 then return dfastate_101
+ if c.ascii == 92 then return dfastate_101
+ if c.ascii == 93 then return dfastate_101
+ if c.ascii == 94 then return dfastate_101
+ if c.ascii == 95 then return dfastate_101
+ if c.ascii == 96 then return dfastate_101
+ if c.ascii == 97 then return dfastate_101
+ if c.ascii == 98 then return dfastate_101
+ if c.ascii == 99 then return dfastate_101
+ if c.ascii == 100 then return dfastate_101
+ if c.ascii == 101 then return dfastate_101
+ if c.ascii == 102 then return dfastate_101
+ if c.ascii == 103 then return dfastate_101
+ if c.ascii == 104 then return dfastate_101
+ if c.ascii == 105 then return dfastate_101
+ if c.ascii == 106 then return dfastate_101
+ if c.ascii == 107 then return dfastate_101
+ if c.ascii == 108 then return dfastate_101
+ if c.ascii == 109 then return dfastate_101
+ if c.ascii == 110 then return dfastate_101
+ if c.ascii == 111 then return dfastate_101
+ if c.ascii == 112 then return dfastate_101
+ if c.ascii == 113 then return dfastate_101
+ if c.ascii == 114 then return dfastate_101
+ if c.ascii == 115 then return dfastate_101
+ if c.ascii == 116 then return dfastate_101
+ if c.ascii == 117 then return dfastate_101
+ if c.ascii == 118 then return dfastate_101
+ if c.ascii == 119 then return dfastate_101
+ if c.ascii == 120 then return dfastate_101
+ if c.ascii == 121 then return dfastate_101
+ if c.ascii == 122 then return dfastate_101
+ if c.ascii == 123 then return dfastate_101
+ if c.ascii == 124 then return dfastate_101
+ if c.ascii == 125 then return dfastate_101
+ if c.ascii == 126 then return dfastate_101
+ if c.ascii == 13 then return dfastate_102
+ if c.ascii == 10 then return dfastate_103
+ return null
+ end
+end
+class DFAState105
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 97 then return dfastate_107
+ if c.ascii == 65 then return dfastate_108
+ return null
+ end
+end
+class DFAState106
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 97 then return dfastate_107
+ if c.ascii == 65 then return dfastate_108
+ return null
+ end
+end
+class DFAState107
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 116 then return dfastate_109
+ if c.ascii == 84 then return dfastate_110
+ return null
+ end
+end
+class DFAState108
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 116 then return dfastate_109
+ if c.ascii == 84 then return dfastate_110
+ return null
+ end
+end
+class DFAState109
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 101 then return dfastate_111
+ if c.ascii == 69 then return dfastate_112
+ return null
+ end
+end
+class DFAState110
+ super DFAState
+ redef fun trans(c) do
+ if c.ascii == 101 then return dfastate_111
+ if c.ascii == 69 then return dfastate_112
+ return null
+ end
+end
+class DFAState111
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_equate
+ t.position = position
+ t.text = text
+ return t
+ end
+end
+class DFAState112
+ super DFAState
+ redef fun is_accept do return true
+ redef fun make_token(position, text) do
+ var t = new Ntk_equate
+ t.position = position
+ t.text = text
+ return t
+ end
+end
--- /dev/null
+# Parser generated by nitcc
+import nitcc_runtime
+class MyParser
+ super Parser
+ redef fun start_state do return state_Start
+end
+redef class Object
+ private fun state_Start: LRStateStart do return once new LRStateStart
+ private fun state_listing: LRStatelisting do return once new LRStatelisting
+ private fun state_line_43d: LRStateline_43d do return once new LRStateline_43d
+ private fun state_line: LRStateline do return once new LRStateline
+ private fun state_label_decl: LRStatelabel_decl do return once new LRStatelabel_decl
+ private fun state_id: LRStateid do return once new LRStateid
+ private fun state_comment: LRStatecomment do return once new LRStatecomment
+ private fun state_eol: LRStateeol do return once new LRStateeol
+ private fun state_instruction: LRStateinstruction do return once new LRStateinstruction
+ private fun state_directive: LRStatedirective do return once new LRStatedirective
+ private fun state_tk_byte: LRStatetk_byte do return once new LRStatetk_byte
+ private fun state_tk_word: LRStatetk_word do return once new LRStatetk_word
+ private fun state_tk_block: LRStatetk_block do return once new LRStatetk_block
+ private fun state_tk_ascii: LRStatetk_ascii do return once new LRStatetk_ascii
+ private fun state_tk_addrss: LRStatetk_addrss do return once new LRStatetk_addrss
+ private fun state_tk_equate: LRStatetk_equate do return once new LRStatetk_equate
+ private fun state_tk_burn: LRStatetk_burn do return once new LRStatetk_burn
+ private fun state_end_block: LRStateend_block do return once new LRStateend_block
+ private fun state_listing_32dEof: LRStatelisting_32dEof do return once new LRStatelisting_32dEof
+ private fun state_line_43d_32dlabel_decl: LRStateline_43d_32dlabel_decl do return once new LRStateline_43d_32dlabel_decl
+ private fun state_line_43d_32dline: LRStateline_43d_32dline do return once new LRStateline_43d_32dline
+ private fun state_line_43d_32dend_block: LRStateline_43d_32dend_block do return once new LRStateline_43d_32dend_block
+ private fun state_label_decl_32dcomment: LRStatelabel_decl_32dcomment do return once new LRStatelabel_decl_32dcomment
+ private fun state_label_decl_32deol: LRStatelabel_decl_32deol do return once new LRStatelabel_decl_32deol
+ private fun state_label_decl_32dinstruction: LRStatelabel_decl_32dinstruction do return once new LRStatelabel_decl_32dinstruction
+ private fun state_label_decl_32ddirective: LRStatelabel_decl_32ddirective do return once new LRStatelabel_decl_32ddirective
+ private fun state_label_decl_32dend_block: LRStatelabel_decl_32dend_block do return once new LRStatelabel_decl_32dend_block
+ private fun state_label_decl_32did: LRStatelabel_decl_32did do return once new LRStatelabel_decl_32did
+ private fun state_id_32dcolon: LRStateid_32dcolon do return once new LRStateid_32dcolon
+ private fun state_id_32doperand: LRStateid_32doperand do return once new LRStateid_32doperand
+ private fun state_id_32dvalue: LRStateid_32dvalue do return once new LRStateid_32dvalue
+ private fun state_id_32did: LRStateid_32did do return once new LRStateid_32did
+ private fun state_id_32dchar: LRStateid_32dchar do return once new LRStateid_32dchar
+ private fun state_id_32dstring: LRStateid_32dstring do return once new LRStateid_32dstring
+ private fun state_comment_32deol: LRStatecomment_32deol do return once new LRStatecomment_32deol
+ private fun state_instruction_32dcomment: LRStateinstruction_32dcomment do return once new LRStateinstruction_32dcomment
+ private fun state_instruction_32deol: LRStateinstruction_32deol do return once new LRStateinstruction_32deol
+ private fun state_directive_32dcomment: LRStatedirective_32dcomment do return once new LRStatedirective_32dcomment
+ private fun state_directive_32deol: LRStatedirective_32deol do return once new LRStatedirective_32deol
+ private fun state_tk_byte_32dvalue: LRStatetk_byte_32dvalue do return once new LRStatetk_byte_32dvalue
+ private fun state_tk_word_32dvalue: LRStatetk_word_32dvalue do return once new LRStatetk_word_32dvalue
+ private fun state_tk_block_32dvalue: LRStatetk_block_32dvalue do return once new LRStatetk_block_32dvalue
+ private fun state_tk_ascii_32dvalue: LRStatetk_ascii_32dvalue do return once new LRStatetk_ascii_32dvalue
+ private fun state_tk_addrss_32dvalue: LRStatetk_addrss_32dvalue do return once new LRStatetk_addrss_32dvalue
+ private fun state_tk_equate_32dvalue: LRStatetk_equate_32dvalue do return once new LRStatetk_equate_32dvalue
+ private fun state_tk_burn_32dvalue: LRStatetk_burn_32dvalue do return once new LRStatetk_burn_32dvalue
+ private fun state_line_43d_32dlabel_decl_32dend_block: LRStateline_43d_32dlabel_decl_32dend_block do return once new LRStateline_43d_32dlabel_decl_32dend_block
+ private fun state_label_decl_32dcomment_32deol: LRStatelabel_decl_32dcomment_32deol do return once new LRStatelabel_decl_32dcomment_32deol
+ private fun state_label_decl_32dinstruction_32dcomment: LRStatelabel_decl_32dinstruction_32dcomment do return once new LRStatelabel_decl_32dinstruction_32dcomment
+ private fun state_label_decl_32dinstruction_32deol: LRStatelabel_decl_32dinstruction_32deol do return once new LRStatelabel_decl_32dinstruction_32deol
+ private fun state_label_decl_32ddirective_32dcomment: LRStatelabel_decl_32ddirective_32dcomment do return once new LRStatelabel_decl_32ddirective_32dcomment
+ private fun state_label_decl_32ddirective_32deol: LRStatelabel_decl_32ddirective_32deol do return once new LRStatelabel_decl_32ddirective_32deol
+ private fun state_id_32dvalue_32dcomma: LRStateid_32dvalue_32dcomma do return once new LRStateid_32dvalue_32dcomma
+ private fun state_instruction_32dcomment_32deol: LRStateinstruction_32dcomment_32deol do return once new LRStateinstruction_32dcomment_32deol
+ private fun state_directive_32dcomment_32deol: LRStatedirective_32dcomment_32deol do return once new LRStatedirective_32dcomment_32deol
+ private fun state_label_decl_32dinstruction_32dcomment_32deol: LRStatelabel_decl_32dinstruction_32dcomment_32deol do return once new LRStatelabel_decl_32dinstruction_32dcomment_32deol
+ private fun state_label_decl_32ddirective_32dcomment_32deol: LRStatelabel_decl_32ddirective_32dcomment_32deol do return once new LRStatelabel_decl_32ddirective_32dcomment_32deol
+ private fun state_id_32dvalue_32dcomma_32did: LRStateid_32dvalue_32dcomma_32did do return once new LRStateid_32dvalue_32dcomma_32did
+ private fun goto_Nlisting: Goto_Nlisting do return once new Goto_Nlisting
+ private fun goto_Nline: Goto_Nline do return once new Goto_Nline
+ private fun goto_Nlabel_decl: Goto_Nlabel_decl do return once new Goto_Nlabel_decl
+ private fun goto_Ninstruction: Goto_Ninstruction do return once new Goto_Ninstruction
+ private fun goto_Noperand: Goto_Noperand do return once new Goto_Noperand
+ private fun goto_Nvalue: Goto_Nvalue do return once new Goto_Nvalue
+ private fun goto_Ndirective: Goto_Ndirective do return once new Goto_Ndirective
+ private fun goto_Nline_43d: Goto_Nline_43d do return once new Goto_Nline_43d
+ private fun goto_N_start: Goto_N_start do return once new Goto_N_start
+end
+redef class NToken
+ # guarded action for state Start
+ # 11 shift(s) and 0 reduce(s)
+ private fun action_sStart(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state listing
+ # 1 shift(s) and 0 reduce(s)
+ private fun action_slisting(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state line+
+ # 11 shift(s) and 0 reduce(s)
+ private fun action_sline_43d(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state label_decl
+ # 11 shift(s) and 0 reduce(s)
+ private fun action_slabel_decl(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state id
+ # 4 shift(s) and 1 reduce(s)
+ private fun action_sid(parser: Parser) do
+ # REDUCE instruction::instruction_unary=id
+ var n0 = parser.pop.as(Nid)
+ var p1 = new Ninstruction_unary(n0)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ninstruction)
+ end
+ # guarded action for state comment
+ # 1 shift(s) and 0 reduce(s)
+ private fun action_scomment(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state instruction
+ # 2 shift(s) and 0 reduce(s)
+ private fun action_sinstruction(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state directive
+ # 2 shift(s) and 0 reduce(s)
+ private fun action_sdirective(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state tk_byte
+ # 3 shift(s) and 0 reduce(s)
+ private fun action_stk_byte(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state tk_word
+ # 3 shift(s) and 0 reduce(s)
+ private fun action_stk_word(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state tk_block
+ # 3 shift(s) and 0 reduce(s)
+ private fun action_stk_block(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state tk_ascii
+ # 3 shift(s) and 0 reduce(s)
+ private fun action_stk_ascii(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state tk_addrss
+ # 3 shift(s) and 0 reduce(s)
+ private fun action_stk_addrss(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state tk_equate
+ # 3 shift(s) and 0 reduce(s)
+ private fun action_stk_equate(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state tk_burn
+ # 3 shift(s) and 0 reduce(s)
+ private fun action_stk_burn(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state line+ label_decl
+ # 11 shift(s) and 0 reduce(s)
+ private fun action_sline_43d_32dlabel_decl(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state label_decl comment
+ # 1 shift(s) and 0 reduce(s)
+ private fun action_slabel_decl_32dcomment(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state label_decl instruction
+ # 2 shift(s) and 0 reduce(s)
+ private fun action_slabel_decl_32dinstruction(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state label_decl directive
+ # 2 shift(s) and 0 reduce(s)
+ private fun action_slabel_decl_32ddirective(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state label_decl id
+ # 3 shift(s) and 1 reduce(s)
+ private fun action_slabel_decl_32did(parser: Parser) do
+ # REDUCE instruction::instruction_unary=id
+ var n0 = parser.pop.as(Nid)
+ var p1 = new Ninstruction_unary(n0)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ninstruction)
+ end
+ # guarded action for state id value
+ # 1 shift(s) and 1 reduce(s)
+ private fun action_sid_32dvalue(parser: Parser) do
+ # REDUCE operand::operand_immediate=value
+ var n0 = parser.pop.as(Nvalue)
+ var p1 = new Noperand_immediate(n0)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Noperand)
+ end
+ # guarded action for state instruction comment
+ # 1 shift(s) and 0 reduce(s)
+ private fun action_sinstruction_32dcomment(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state directive comment
+ # 1 shift(s) and 0 reduce(s)
+ private fun action_sdirective_32dcomment(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state label_decl instruction comment
+ # 1 shift(s) and 0 reduce(s)
+ private fun action_slabel_decl_32dinstruction_32dcomment(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state label_decl directive comment
+ # 1 shift(s) and 0 reduce(s)
+ private fun action_slabel_decl_32ddirective_32dcomment(parser: Parser) do
+ parser.parse_error
+ end
+ # guarded action for state id value comma
+ # 1 shift(s) and 0 reduce(s)
+ private fun action_sid_32dvalue_32dcomma(parser: Parser) do
+ parser.parse_error
+ end
+end
+class NIgnored
+ super NToken
+ redef fun node_name do return "Ignored"
+end
+class Nend_block
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_end_block)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_line_43d_32dend_block)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_label_decl_32dend_block)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_line_43d_32dlabel_decl_32dend_block)
+ end
+ redef fun node_name do return "end_block"
+end
+class Ncomment
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_comment)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_comment)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_label_decl_32dcomment)
+ end
+ redef fun action_sinstruction(parser) do
+ parser.shift(state_instruction_32dcomment)
+ end
+ redef fun action_sdirective(parser) do
+ parser.shift(state_directive_32dcomment)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_label_decl_32dcomment)
+ end
+ redef fun action_slabel_decl_32dinstruction(parser) do
+ parser.shift(state_label_decl_32dinstruction_32dcomment)
+ end
+ redef fun action_slabel_decl_32ddirective(parser) do
+ parser.shift(state_label_decl_32ddirective_32dcomment)
+ end
+ redef fun node_name do return "comment"
+end
+class Neol
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_eol)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_eol)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_label_decl_32deol)
+ end
+ redef fun action_scomment(parser) do
+ parser.shift(state_comment_32deol)
+ end
+ redef fun action_sinstruction(parser) do
+ parser.shift(state_instruction_32deol)
+ end
+ redef fun action_sdirective(parser) do
+ parser.shift(state_directive_32deol)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_label_decl_32deol)
+ end
+ redef fun action_slabel_decl_32dcomment(parser) do
+ parser.shift(state_label_decl_32dcomment_32deol)
+ end
+ redef fun action_slabel_decl_32dinstruction(parser) do
+ parser.shift(state_label_decl_32dinstruction_32deol)
+ end
+ redef fun action_slabel_decl_32ddirective(parser) do
+ parser.shift(state_label_decl_32ddirective_32deol)
+ end
+ redef fun action_sinstruction_32dcomment(parser) do
+ parser.shift(state_instruction_32dcomment_32deol)
+ end
+ redef fun action_sdirective_32dcomment(parser) do
+ parser.shift(state_directive_32dcomment_32deol)
+ end
+ redef fun action_slabel_decl_32dinstruction_32dcomment(parser) do
+ parser.shift(state_label_decl_32dinstruction_32dcomment_32deol)
+ end
+ redef fun action_slabel_decl_32ddirective_32dcomment(parser) do
+ parser.shift(state_label_decl_32ddirective_32dcomment_32deol)
+ end
+ redef fun node_name do return "eol"
+end
+class Nid
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_id)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_id)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_label_decl_32did)
+ end
+ redef fun action_sid(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_stk_byte(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_stk_word(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_stk_block(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_stk_ascii(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_stk_addrss(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_stk_equate(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_stk_burn(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_label_decl_32did)
+ end
+ redef fun action_slabel_decl_32did(parser) do
+ parser.shift(state_id_32did)
+ end
+ redef fun action_sid_32dvalue_32dcomma(parser) do
+ parser.shift(state_id_32dvalue_32dcomma_32did)
+ end
+ redef fun node_name do return "id"
+end
+class Ncolon
+ super NToken
+ redef fun action_sid(parser) do
+ parser.shift(state_id_32dcolon)
+ end
+ redef fun node_name do return "colon"
+end
+class Ncomma
+ super NToken
+ redef fun action_sid_32dvalue(parser) do
+ parser.shift(state_id_32dvalue_32dcomma)
+ end
+ redef fun node_name do return "comma"
+end
+class Nchar
+ super NToken
+ redef fun action_sid(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun action_stk_byte(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun action_stk_word(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun action_stk_block(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun action_stk_ascii(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun action_stk_addrss(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun action_stk_equate(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun action_stk_burn(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun action_slabel_decl_32did(parser) do
+ parser.shift(state_id_32dchar)
+ end
+ redef fun node_name do return "char"
+end
+class Nstring
+ super NToken
+ redef fun action_sid(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun action_stk_byte(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun action_stk_word(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun action_stk_block(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun action_stk_ascii(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun action_stk_addrss(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun action_stk_equate(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun action_stk_burn(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun action_slabel_decl_32did(parser) do
+ parser.shift(state_id_32dstring)
+ end
+ redef fun node_name do return "string"
+end
+class Ntk_byte
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_tk_byte)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_tk_byte)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_tk_byte)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_tk_byte)
+ end
+ redef fun node_name do return "tk_byte"
+end
+class Ntk_word
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_tk_word)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_tk_word)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_tk_word)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_tk_word)
+ end
+ redef fun node_name do return "tk_word"
+end
+class Ntk_block
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_tk_block)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_tk_block)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_tk_block)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_tk_block)
+ end
+ redef fun node_name do return "tk_block"
+end
+class Ntk_ascii
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_tk_ascii)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_tk_ascii)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_tk_ascii)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_tk_ascii)
+ end
+ redef fun node_name do return "tk_ascii"
+end
+class Ntk_addrss
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_tk_addrss)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_tk_addrss)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_tk_addrss)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_tk_addrss)
+ end
+ redef fun node_name do return "tk_addrss"
+end
+class Ntk_equate
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_tk_equate)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_tk_equate)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_tk_equate)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_tk_equate)
+ end
+ redef fun node_name do return "tk_equate"
+end
+class Ntk_burn
+ super NToken
+ redef fun action_sStart(parser) do
+ parser.shift(state_tk_burn)
+ end
+ redef fun action_sline_43d(parser) do
+ parser.shift(state_tk_burn)
+ end
+ redef fun action_slabel_decl(parser) do
+ parser.shift(state_tk_burn)
+ end
+ redef fun action_sline_43d_32dlabel_decl(parser) do
+ parser.shift(state_tk_burn)
+ end
+ redef fun node_name do return "tk_burn"
+end
+redef class NEof
+ super NToken
+ redef fun action_slisting(parser) do
+ parser.shift(state_listing_32dEof)
+ end
+ redef fun node_name do return "Eof"
+end
+redef class LRGoto
+ private fun goto_sStart(parser: Parser) do abort
+ private fun goto_sline_43d(parser: Parser) do abort
+ private fun goto_slabel_decl(parser: Parser) do abort
+ private fun goto_sid(parser: Parser) do abort
+ private fun goto_sline_43d_32dlabel_decl(parser: Parser) do abort
+ private fun goto_slabel_decl_32did(parser: Parser) do abort
+end
+class Goto_Nlisting
+ super LRGoto
+ redef fun goto_sStart(parser) do
+ parser.push(state_listing)
+ end
+end
+class Goto_Nline
+ super LRGoto
+ redef fun goto_sStart(parser) do
+ parser.push(state_line)
+ end
+ redef fun goto_sline_43d(parser) do
+ parser.push(state_line_43d_32dline)
+ end
+end
+class Goto_Nlabel_decl
+ super LRGoto
+ redef fun goto_sStart(parser) do
+ parser.push(state_label_decl)
+ end
+ redef fun goto_sline_43d(parser) do
+ parser.push(state_line_43d_32dlabel_decl)
+ end
+end
+class Goto_Ninstruction
+ super LRGoto
+ redef fun goto_sStart(parser) do
+ parser.push(state_instruction)
+ end
+ redef fun goto_sline_43d(parser) do
+ parser.push(state_instruction)
+ end
+ redef fun goto_slabel_decl(parser) do
+ parser.push(state_label_decl_32dinstruction)
+ end
+ redef fun goto_sline_43d_32dlabel_decl(parser) do
+ parser.push(state_label_decl_32dinstruction)
+ end
+end
+class Goto_Noperand
+ super LRGoto
+ redef fun goto_sid(parser) do
+ parser.push(state_id_32doperand)
+ end
+ redef fun goto_slabel_decl_32did(parser) do
+ parser.push(state_id_32doperand)
+ end
+end
+class Goto_Nvalue
+ super LRGoto
+ redef fun goto_sid(parser) do
+ parser.push(state_id_32dvalue)
+ end
+ redef fun goto_slabel_decl_32did(parser) do
+ parser.push(state_id_32dvalue)
+ end
+end
+class Goto_Ndirective
+ super LRGoto
+ redef fun goto_sStart(parser) do
+ parser.push(state_directive)
+ end
+ redef fun goto_sline_43d(parser) do
+ parser.push(state_directive)
+ end
+ redef fun goto_slabel_decl(parser) do
+ parser.push(state_label_decl_32ddirective)
+ end
+ redef fun goto_sline_43d_32dlabel_decl(parser) do
+ parser.push(state_label_decl_32ddirective)
+ end
+end
+class Goto_Nline_43d
+ super LRGoto
+ redef fun goto_sStart(parser) do
+ parser.push(state_line_43d)
+ end
+end
+class Goto_N_start
+ super LRGoto
+end
+class Nlisting
+ super NProd
+ redef fun node_name do return "listing"
+ var n_lines: nullable Nodes[Nline]
+ var n_label_decl: nullable Nlabel_decl
+ var n_end_block: Nend_block
+ init(n_lines: nullable Nodes[Nline], n_label_decl: nullable Nlabel_decl, n_end_block: Nend_block) do
+ self.n_lines = n_lines
+ self.n_label_decl = n_label_decl
+ self.n_end_block = n_end_block
+ end
+ redef fun number_of_children do return 3
+ redef fun child(i) do
+ if i == 0 then return n_lines
+ if i == 1 then return n_label_decl
+ if i == 2 then return n_end_block
+ abort
+ end
+end
+class Nline
+ super NProd
+ redef fun node_name do return "line"
+end
+class Nline_empty
+ super Nline
+ redef fun node_name do return "line_empty"
+ var n_label_decl: nullable Nlabel_decl
+ var n_comment: nullable Ncomment
+ var n_eol: Neol
+ init(n_label_decl: nullable Nlabel_decl, n_comment: nullable Ncomment, n_eol: Neol) do
+ self.n_label_decl = n_label_decl
+ self.n_comment = n_comment
+ self.n_eol = n_eol
+ end
+ redef fun number_of_children do return 3
+ redef fun child(i) do
+ if i == 0 then return n_label_decl
+ if i == 1 then return n_comment
+ if i == 2 then return n_eol
+ abort
+ end
+end
+class Nline_instruction
+ super Nline
+ redef fun node_name do return "line_instruction"
+ var n_label_decl: nullable Nlabel_decl
+ var n_instruction: Ninstruction
+ var n_comment: nullable Ncomment
+ var n_eol: Neol
+ init(n_label_decl: nullable Nlabel_decl, n_instruction: Ninstruction, n_comment: nullable Ncomment, n_eol: Neol) do
+ self.n_label_decl = n_label_decl
+ self.n_instruction = n_instruction
+ self.n_comment = n_comment
+ self.n_eol = n_eol
+ end
+ redef fun number_of_children do return 4
+ redef fun child(i) do
+ if i == 0 then return n_label_decl
+ if i == 1 then return n_instruction
+ if i == 2 then return n_comment
+ if i == 3 then return n_eol
+ abort
+ end
+end
+class Nline_directive
+ super Nline
+ redef fun node_name do return "line_directive"
+ var n_label_decl: nullable Nlabel_decl
+ var n_directive: Ndirective
+ var n_comment: nullable Ncomment
+ var n_eol: Neol
+ init(n_label_decl: nullable Nlabel_decl, n_directive: Ndirective, n_comment: nullable Ncomment, n_eol: Neol) do
+ self.n_label_decl = n_label_decl
+ self.n_directive = n_directive
+ self.n_comment = n_comment
+ self.n_eol = n_eol
+ end
+ redef fun number_of_children do return 4
+ redef fun child(i) do
+ if i == 0 then return n_label_decl
+ if i == 1 then return n_directive
+ if i == 2 then return n_comment
+ if i == 3 then return n_eol
+ abort
+ end
+end
+class Nlabel_decl
+ super NProd
+ redef fun node_name do return "label_decl"
+ var n_id: Nid
+ var n_colon: Ncolon
+ init(n_id: Nid, n_colon: Ncolon) do
+ self.n_id = n_id
+ self.n_colon = n_colon
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_id
+ if i == 1 then return n_colon
+ abort
+ end
+end
+class Ninstruction
+ super NProd
+ redef fun node_name do return "instruction"
+end
+class Ninstruction_unary
+ super Ninstruction
+ redef fun node_name do return "instruction_unary"
+ var n_id: Nid
+ init(n_id: Nid) do
+ self.n_id = n_id
+ end
+ redef fun number_of_children do return 1
+ redef fun child(i) do
+ if i == 0 then return n_id
+ abort
+ end
+end
+class Ninstruction_binary
+ super Ninstruction
+ redef fun node_name do return "instruction_binary"
+ var n_id: Nid
+ var n_operand: Noperand
+ init(n_id: Nid, n_operand: Noperand) do
+ self.n_id = n_id
+ self.n_operand = n_operand
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_id
+ if i == 1 then return n_operand
+ abort
+ end
+end
+class Noperand
+ super NProd
+ redef fun node_name do return "operand"
+end
+class Noperand_immediate
+ super Noperand
+ redef fun node_name do return "operand_immediate"
+ var n_value: Nvalue
+ init(n_value: Nvalue) do
+ self.n_value = n_value
+ end
+ redef fun number_of_children do return 1
+ redef fun child(i) do
+ if i == 0 then return n_value
+ abort
+ end
+end
+class Noperand_any
+ super Noperand
+ redef fun node_name do return "operand_any"
+ var n_value: Nvalue
+ var n_comma: Ncomma
+ var n_id: Nid
+ init(n_value: Nvalue, n_comma: Ncomma, n_id: Nid) do
+ self.n_value = n_value
+ self.n_comma = n_comma
+ self.n_id = n_id
+ end
+ redef fun number_of_children do return 3
+ redef fun child(i) do
+ if i == 0 then return n_value
+ if i == 1 then return n_comma
+ if i == 2 then return n_id
+ abort
+ end
+end
+class Nvalue
+ super NProd
+ redef fun node_name do return "value"
+end
+class Nvalue_label
+ super Nvalue
+ redef fun node_name do return "value_label"
+ var n_id: Nid
+ init(n_id: Nid) do
+ self.n_id = n_id
+ end
+ redef fun number_of_children do return 1
+ redef fun child(i) do
+ if i == 0 then return n_id
+ abort
+ end
+end
+class Nvalue_char
+ super Nvalue
+ redef fun node_name do return "value_char"
+ var n_char: Nchar
+ init(n_char: Nchar) do
+ self.n_char = n_char
+ end
+ redef fun number_of_children do return 1
+ redef fun child(i) do
+ if i == 0 then return n_char
+ abort
+ end
+end
+class Nvalue_string
+ super Nvalue
+ redef fun node_name do return "value_string"
+ var n_string: Nstring
+ init(n_string: Nstring) do
+ self.n_string = n_string
+ end
+ redef fun number_of_children do return 1
+ redef fun child(i) do
+ if i == 0 then return n_string
+ abort
+ end
+end
+class Ndirective
+ super NProd
+ redef fun node_name do return "directive"
+end
+class Ndirective_byte
+ super Ndirective
+ redef fun node_name do return "directive_byte"
+ var n_tk_byte: Ntk_byte
+ var n_value: Nvalue
+ init(n_tk_byte: Ntk_byte, n_value: Nvalue) do
+ self.n_tk_byte = n_tk_byte
+ self.n_value = n_value
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_tk_byte
+ if i == 1 then return n_value
+ abort
+ end
+end
+class Ndirective_word
+ super Ndirective
+ redef fun node_name do return "directive_word"
+ var n_tk_word: Ntk_word
+ var n_value: Nvalue
+ init(n_tk_word: Ntk_word, n_value: Nvalue) do
+ self.n_tk_word = n_tk_word
+ self.n_value = n_value
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_tk_word
+ if i == 1 then return n_value
+ abort
+ end
+end
+class Ndirective_block
+ super Ndirective
+ redef fun node_name do return "directive_block"
+ var n_tk_block: Ntk_block
+ var n_value: Nvalue
+ init(n_tk_block: Ntk_block, n_value: Nvalue) do
+ self.n_tk_block = n_tk_block
+ self.n_value = n_value
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_tk_block
+ if i == 1 then return n_value
+ abort
+ end
+end
+class Ndirective_ascii
+ super Ndirective
+ redef fun node_name do return "directive_ascii"
+ var n_tk_ascii: Ntk_ascii
+ var n_value: Nvalue
+ init(n_tk_ascii: Ntk_ascii, n_value: Nvalue) do
+ self.n_tk_ascii = n_tk_ascii
+ self.n_value = n_value
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_tk_ascii
+ if i == 1 then return n_value
+ abort
+ end
+end
+class Ndirective_addrss
+ super Ndirective
+ redef fun node_name do return "directive_addrss"
+ var n_tk_addrss: Ntk_addrss
+ var n_value: Nvalue
+ init(n_tk_addrss: Ntk_addrss, n_value: Nvalue) do
+ self.n_tk_addrss = n_tk_addrss
+ self.n_value = n_value
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_tk_addrss
+ if i == 1 then return n_value
+ abort
+ end
+end
+class Ndirective_equate
+ super Ndirective
+ redef fun node_name do return "directive_equate"
+ var n_tk_equate: Ntk_equate
+ var n_value: Nvalue
+ init(n_tk_equate: Ntk_equate, n_value: Nvalue) do
+ self.n_tk_equate = n_tk_equate
+ self.n_value = n_value
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_tk_equate
+ if i == 1 then return n_value
+ abort
+ end
+end
+class Ndirective_burn
+ super Ndirective
+ redef fun node_name do return "directive_burn"
+ var n_tk_burn: Ntk_burn
+ var n_value: Nvalue
+ init(n_tk_burn: Ntk_burn, n_value: Nvalue) do
+ self.n_tk_burn = n_tk_burn
+ self.n_value = n_value
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_tk_burn
+ if i == 1 then return n_value
+ abort
+ end
+end
+class N_start
+ super NProd
+ redef fun node_name do return "_start"
+end
+class NStart
+ super N_start
+ redef fun node_name do return "Start"
+ var n_0: Nlisting
+ var n_1: NEof
+ init(n_0: Nlisting, n_1: NEof) do
+ self.n_0 = n_0
+ self.n_1 = n_1
+ end
+ redef fun number_of_children do return 2
+ redef fun child(i) do
+ if i == 0 then return n_0
+ if i == 1 then return n_1
+ abort
+ end
+end
+# State Start
+private class LRStateStart
+ super LRState
+ redef fun to_s do return "Start"
+ redef fun error_msg do return "listing, line+, line, label_decl, instruction, directive"
+ redef fun action(parser) do
+ parser.peek_token.action_sStart(parser)
+ end
+ redef fun goto(parser, goto) do
+ goto.goto_sStart(parser)
+ end
+end
+# State listing
+private class LRStatelisting
+ super LRState
+ redef fun to_s do return "listing"
+ redef fun error_msg do return "Eof"
+ redef fun action(parser) do
+ parser.peek_token.action_slisting(parser)
+ end
+end
+# State line+
+private class LRStateline_43d
+ super LRState
+ redef fun to_s do return "line+"
+ redef fun error_msg do return "label_decl, line, instruction, directive"
+ redef fun action(parser) do
+ parser.peek_token.action_sline_43d(parser)
+ end
+ redef fun goto(parser, goto) do
+ goto.goto_sline_43d(parser)
+ end
+end
+# State line
+private class LRStateline
+ super LRState
+ redef fun to_s do return "line"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line+::line+_one=line
+ var n0 = parser.pop.as(Nline)
+ var prod = new Nodes[Nline]
+ prod.items.add(n0)
+ parser.node_stack.push prod
+ parser.goto(goto_Nline_43d)
+ end
+end
+# State label_decl
+private class LRStatelabel_decl
+ super LRState
+ redef fun to_s do return "label_decl"
+ redef fun error_msg do return "instruction, directive"
+ redef fun action(parser) do
+ parser.peek_token.action_slabel_decl(parser)
+ end
+ redef fun goto(parser, goto) do
+ goto.goto_slabel_decl(parser)
+ end
+end
+# State id
+private class LRStateid
+ super LRState
+ redef fun to_s do return "id"
+ redef fun error_msg do return "operand, value"
+ redef fun action(parser) do
+ parser.peek_token.action_sid(parser)
+ end
+ redef fun goto(parser, goto) do
+ goto.goto_sid(parser)
+ end
+end
+# State comment
+private class LRStatecomment
+ super LRState
+ redef fun to_s do return "comment"
+ redef fun error_msg do return "eol"
+ redef fun action(parser) do
+ parser.peek_token.action_scomment(parser)
+ end
+end
+# State eol
+private class LRStateeol
+ super LRState
+ redef fun to_s do return "eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_empty_3=eol
+ var n0 = parser.pop.as(Neol)
+ var p1 = new Nline_empty(null, null, n0)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State instruction
+private class LRStateinstruction
+ super LRState
+ redef fun to_s do return "instruction"
+ redef fun error_msg do return "comment, eol"
+ redef fun action(parser) do
+ parser.peek_token.action_sinstruction(parser)
+ end
+end
+# State directive
+private class LRStatedirective
+ super LRState
+ redef fun to_s do return "directive"
+ redef fun error_msg do return "comment, eol"
+ redef fun action(parser) do
+ parser.peek_token.action_sdirective(parser)
+ end
+end
+# State tk_byte
+private class LRStatetk_byte
+ super LRState
+ redef fun to_s do return "tk_byte"
+ redef fun error_msg do return "value"
+ redef fun action(parser) do
+ parser.peek_token.action_stk_byte(parser)
+ end
+ redef fun goto(parser, goto) do
+ parser.push(state_tk_byte_32dvalue)
+ end
+end
+# State tk_word
+private class LRStatetk_word
+ super LRState
+ redef fun to_s do return "tk_word"
+ redef fun error_msg do return "value"
+ redef fun action(parser) do
+ parser.peek_token.action_stk_word(parser)
+ end
+ redef fun goto(parser, goto) do
+ parser.push(state_tk_word_32dvalue)
+ end
+end
+# State tk_block
+private class LRStatetk_block
+ super LRState
+ redef fun to_s do return "tk_block"
+ redef fun error_msg do return "value"
+ redef fun action(parser) do
+ parser.peek_token.action_stk_block(parser)
+ end
+ redef fun goto(parser, goto) do
+ parser.push(state_tk_block_32dvalue)
+ end
+end
+# State tk_ascii
+private class LRStatetk_ascii
+ super LRState
+ redef fun to_s do return "tk_ascii"
+ redef fun error_msg do return "value"
+ redef fun action(parser) do
+ parser.peek_token.action_stk_ascii(parser)
+ end
+ redef fun goto(parser, goto) do
+ parser.push(state_tk_ascii_32dvalue)
+ end
+end
+# State tk_addrss
+private class LRStatetk_addrss
+ super LRState
+ redef fun to_s do return "tk_addrss"
+ redef fun error_msg do return "value"
+ redef fun action(parser) do
+ parser.peek_token.action_stk_addrss(parser)
+ end
+ redef fun goto(parser, goto) do
+ parser.push(state_tk_addrss_32dvalue)
+ end
+end
+# State tk_equate
+private class LRStatetk_equate
+ super LRState
+ redef fun to_s do return "tk_equate"
+ redef fun error_msg do return "value"
+ redef fun action(parser) do
+ parser.peek_token.action_stk_equate(parser)
+ end
+ redef fun goto(parser, goto) do
+ parser.push(state_tk_equate_32dvalue)
+ end
+end
+# State tk_burn
+private class LRStatetk_burn
+ super LRState
+ redef fun to_s do return "tk_burn"
+ redef fun error_msg do return "value"
+ redef fun action(parser) do
+ parser.peek_token.action_stk_burn(parser)
+ end
+ redef fun goto(parser, goto) do
+ parser.push(state_tk_burn_32dvalue)
+ end
+end
+# State end_block
+private class LRStateend_block
+ super LRState
+ redef fun to_s do return "end_block"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE listing::listing_3=end_block
+ var n0 = parser.pop.as(Nend_block)
+ var p1 = new Nlisting(null, null, n0)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nlisting)
+ end
+end
+# State listing Eof
+private class LRStatelisting_32dEof
+ super LRState
+ redef fun to_s do return "listing Eof"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE _start::Start=listing Eof
+ var n1 = parser.pop.as(NEof)
+ var n0 = parser.pop.as(Nlisting)
+ var p1 = new NStart(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.stop = true
+ end
+end
+# State line+ label_decl
+private class LRStateline_43d_32dlabel_decl
+ super LRState
+ redef fun to_s do return "line+ label_decl"
+ redef fun error_msg do return "instruction, directive"
+ redef fun action(parser) do
+ parser.peek_token.action_sline_43d_32dlabel_decl(parser)
+ end
+ redef fun goto(parser, goto) do
+ goto.goto_sline_43d_32dlabel_decl(parser)
+ end
+end
+# State line+ line
+private class LRStateline_43d_32dline
+ super LRState
+ redef fun to_s do return "line+ line"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line+::line+_more=line+ line
+ var n1 = parser.pop.as(Nline)
+ var n0 = parser.pop.as(Nodes[Nline])
+ var prod = n0
+ n0.items.add(n1)
+ parser.node_stack.push prod
+ parser.goto(goto_Nline_43d)
+ end
+end
+# State line+ end_block
+private class LRStateline_43d_32dend_block
+ super LRState
+ redef fun to_s do return "line+ end_block"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE listing::listing_2=line+ end_block
+ var n1 = parser.pop.as(Nend_block)
+ var n0 = parser.pop.as(Nodes[Nline])
+ var p1 = new Nlisting(n0, null, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nlisting)
+ end
+end
+# State label_decl comment
+private class LRStatelabel_decl_32dcomment
+ super LRState
+ redef fun to_s do return "label_decl comment"
+ redef fun error_msg do return "eol"
+ redef fun action(parser) do
+ parser.peek_token.action_slabel_decl_32dcomment(parser)
+ end
+end
+# State label_decl eol
+private class LRStatelabel_decl_32deol
+ super LRState
+ redef fun to_s do return "label_decl eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_empty_2=label_decl eol
+ var n1 = parser.pop.as(Neol)
+ var n0 = parser.pop.as(Nlabel_decl)
+ var p1 = new Nline_empty(n0, null, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State label_decl instruction
+private class LRStatelabel_decl_32dinstruction
+ super LRState
+ redef fun to_s do return "label_decl instruction"
+ redef fun error_msg do return "comment, eol"
+ redef fun action(parser) do
+ parser.peek_token.action_slabel_decl_32dinstruction(parser)
+ end
+end
+# State label_decl directive
+private class LRStatelabel_decl_32ddirective
+ super LRState
+ redef fun to_s do return "label_decl directive"
+ redef fun error_msg do return "comment, eol"
+ redef fun action(parser) do
+ parser.peek_token.action_slabel_decl_32ddirective(parser)
+ end
+end
+# State label_decl end_block
+private class LRStatelabel_decl_32dend_block
+ super LRState
+ redef fun to_s do return "label_decl end_block"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE listing::listing_1=label_decl end_block
+ var n1 = parser.pop.as(Nend_block)
+ var n0 = parser.pop.as(Nlabel_decl)
+ var p1 = new Nlisting(null, n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nlisting)
+ end
+end
+# State label_decl id
+private class LRStatelabel_decl_32did
+ super LRState
+ redef fun to_s do return "label_decl id"
+ redef fun error_msg do return "operand, value"
+ redef fun action(parser) do
+ parser.peek_token.action_slabel_decl_32did(parser)
+ end
+ redef fun goto(parser, goto) do
+ goto.goto_slabel_decl_32did(parser)
+ end
+end
+# State id colon
+private class LRStateid_32dcolon
+ super LRState
+ redef fun to_s do return "id colon"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE label_decl::label_decl=id colon
+ var n1 = parser.pop.as(Ncolon)
+ var n0 = parser.pop.as(Nid)
+ var p1 = new Nlabel_decl(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nlabel_decl)
+ end
+end
+# State id operand
+private class LRStateid_32doperand
+ super LRState
+ redef fun to_s do return "id operand"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE instruction::instruction_binary=id operand
+ var n1 = parser.pop.as(Noperand)
+ var n0 = parser.pop.as(Nid)
+ var p1 = new Ninstruction_binary(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ninstruction)
+ end
+end
+# State id value
+private class LRStateid_32dvalue
+ super LRState
+ redef fun to_s do return "id value"
+ redef fun error_msg do return "comma"
+ redef fun action(parser) do
+ parser.peek_token.action_sid_32dvalue(parser)
+ end
+end
+# State id id
+private class LRStateid_32did
+ super LRState
+ redef fun to_s do return "id id"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE value::value_label=id
+ var n0 = parser.pop.as(Nid)
+ var p1 = new Nvalue_label(n0)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nvalue)
+ end
+end
+# State id char
+private class LRStateid_32dchar
+ super LRState
+ redef fun to_s do return "id char"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE value::value_char=char
+ var n0 = parser.pop.as(Nchar)
+ var p1 = new Nvalue_char(n0)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nvalue)
+ end
+end
+# State id string
+private class LRStateid_32dstring
+ super LRState
+ redef fun to_s do return "id string"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE value::value_string=string
+ var n0 = parser.pop.as(Nstring)
+ var p1 = new Nvalue_string(n0)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nvalue)
+ end
+end
+# State comment eol
+private class LRStatecomment_32deol
+ super LRState
+ redef fun to_s do return "comment eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_empty_1=comment eol
+ var n1 = parser.pop.as(Neol)
+ var n0 = parser.pop.as(Ncomment)
+ var p1 = new Nline_empty(null, n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State instruction comment
+private class LRStateinstruction_32dcomment
+ super LRState
+ redef fun to_s do return "instruction comment"
+ redef fun error_msg do return "eol"
+ redef fun action(parser) do
+ parser.peek_token.action_sinstruction_32dcomment(parser)
+ end
+end
+# State instruction eol
+private class LRStateinstruction_32deol
+ super LRState
+ redef fun to_s do return "instruction eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_instruction_3=instruction eol
+ var n1 = parser.pop.as(Neol)
+ var n0 = parser.pop.as(Ninstruction)
+ var p1 = new Nline_instruction(null, n0, null, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State directive comment
+private class LRStatedirective_32dcomment
+ super LRState
+ redef fun to_s do return "directive comment"
+ redef fun error_msg do return "eol"
+ redef fun action(parser) do
+ parser.peek_token.action_sdirective_32dcomment(parser)
+ end
+end
+# State directive eol
+private class LRStatedirective_32deol
+ super LRState
+ redef fun to_s do return "directive eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_directive_3=directive eol
+ var n1 = parser.pop.as(Neol)
+ var n0 = parser.pop.as(Ndirective)
+ var p1 = new Nline_directive(null, n0, null, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State tk_byte value
+private class LRStatetk_byte_32dvalue
+ super LRState
+ redef fun to_s do return "tk_byte value"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE directive::directive_byte=tk_byte value
+ var n1 = parser.pop.as(Nvalue)
+ var n0 = parser.pop.as(Ntk_byte)
+ var p1 = new Ndirective_byte(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ndirective)
+ end
+end
+# State tk_word value
+private class LRStatetk_word_32dvalue
+ super LRState
+ redef fun to_s do return "tk_word value"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE directive::directive_word=tk_word value
+ var n1 = parser.pop.as(Nvalue)
+ var n0 = parser.pop.as(Ntk_word)
+ var p1 = new Ndirective_word(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ndirective)
+ end
+end
+# State tk_block value
+private class LRStatetk_block_32dvalue
+ super LRState
+ redef fun to_s do return "tk_block value"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE directive::directive_block=tk_block value
+ var n1 = parser.pop.as(Nvalue)
+ var n0 = parser.pop.as(Ntk_block)
+ var p1 = new Ndirective_block(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ndirective)
+ end
+end
+# State tk_ascii value
+private class LRStatetk_ascii_32dvalue
+ super LRState
+ redef fun to_s do return "tk_ascii value"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE directive::directive_ascii=tk_ascii value
+ var n1 = parser.pop.as(Nvalue)
+ var n0 = parser.pop.as(Ntk_ascii)
+ var p1 = new Ndirective_ascii(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ndirective)
+ end
+end
+# State tk_addrss value
+private class LRStatetk_addrss_32dvalue
+ super LRState
+ redef fun to_s do return "tk_addrss value"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE directive::directive_addrss=tk_addrss value
+ var n1 = parser.pop.as(Nvalue)
+ var n0 = parser.pop.as(Ntk_addrss)
+ var p1 = new Ndirective_addrss(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ndirective)
+ end
+end
+# State tk_equate value
+private class LRStatetk_equate_32dvalue
+ super LRState
+ redef fun to_s do return "tk_equate value"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE directive::directive_equate=tk_equate value
+ var n1 = parser.pop.as(Nvalue)
+ var n0 = parser.pop.as(Ntk_equate)
+ var p1 = new Ndirective_equate(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ndirective)
+ end
+end
+# State tk_burn value
+private class LRStatetk_burn_32dvalue
+ super LRState
+ redef fun to_s do return "tk_burn value"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE directive::directive_burn=tk_burn value
+ var n1 = parser.pop.as(Nvalue)
+ var n0 = parser.pop.as(Ntk_burn)
+ var p1 = new Ndirective_burn(n0, n1)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Ndirective)
+ end
+end
+# State line+ label_decl end_block
+private class LRStateline_43d_32dlabel_decl_32dend_block
+ super LRState
+ redef fun to_s do return "line+ label_decl end_block"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE listing::listing_0=line+ label_decl end_block
+ var n2 = parser.pop.as(Nend_block)
+ var n1 = parser.pop.as(Nlabel_decl)
+ var n0 = parser.pop.as(Nodes[Nline])
+ var p1 = new Nlisting(n0, n1, n2)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nlisting)
+ end
+end
+# State label_decl comment eol
+private class LRStatelabel_decl_32dcomment_32deol
+ super LRState
+ redef fun to_s do return "label_decl comment eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_empty_0=label_decl comment eol
+ var n2 = parser.pop.as(Neol)
+ var n1 = parser.pop.as(Ncomment)
+ var n0 = parser.pop.as(Nlabel_decl)
+ var p1 = new Nline_empty(n0, n1, n2)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State label_decl instruction comment
+private class LRStatelabel_decl_32dinstruction_32dcomment
+ super LRState
+ redef fun to_s do return "label_decl instruction comment"
+ redef fun error_msg do return "eol"
+ redef fun action(parser) do
+ parser.peek_token.action_slabel_decl_32dinstruction_32dcomment(parser)
+ end
+end
+# State label_decl instruction eol
+private class LRStatelabel_decl_32dinstruction_32deol
+ super LRState
+ redef fun to_s do return "label_decl instruction eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_instruction_2=label_decl instruction eol
+ var n2 = parser.pop.as(Neol)
+ var n1 = parser.pop.as(Ninstruction)
+ var n0 = parser.pop.as(Nlabel_decl)
+ var p1 = new Nline_instruction(n0, n1, null, n2)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State label_decl directive comment
+private class LRStatelabel_decl_32ddirective_32dcomment
+ super LRState
+ redef fun to_s do return "label_decl directive comment"
+ redef fun error_msg do return "eol"
+ redef fun action(parser) do
+ parser.peek_token.action_slabel_decl_32ddirective_32dcomment(parser)
+ end
+end
+# State label_decl directive eol
+private class LRStatelabel_decl_32ddirective_32deol
+ super LRState
+ redef fun to_s do return "label_decl directive eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_directive_2=label_decl directive eol
+ var n2 = parser.pop.as(Neol)
+ var n1 = parser.pop.as(Ndirective)
+ var n0 = parser.pop.as(Nlabel_decl)
+ var p1 = new Nline_directive(n0, n1, null, n2)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State id value comma
+private class LRStateid_32dvalue_32dcomma
+ super LRState
+ redef fun to_s do return "id value comma"
+ redef fun error_msg do return "id"
+ redef fun action(parser) do
+ parser.peek_token.action_sid_32dvalue_32dcomma(parser)
+ end
+end
+# State instruction comment eol
+private class LRStateinstruction_32dcomment_32deol
+ super LRState
+ redef fun to_s do return "instruction comment eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_instruction_1=instruction comment eol
+ var n2 = parser.pop.as(Neol)
+ var n1 = parser.pop.as(Ncomment)
+ var n0 = parser.pop.as(Ninstruction)
+ var p1 = new Nline_instruction(null, n0, n1, n2)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State directive comment eol
+private class LRStatedirective_32dcomment_32deol
+ super LRState
+ redef fun to_s do return "directive comment eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_directive_1=directive comment eol
+ var n2 = parser.pop.as(Neol)
+ var n1 = parser.pop.as(Ncomment)
+ var n0 = parser.pop.as(Ndirective)
+ var p1 = new Nline_directive(null, n0, n1, n2)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State label_decl instruction comment eol
+private class LRStatelabel_decl_32dinstruction_32dcomment_32deol
+ super LRState
+ redef fun to_s do return "label_decl instruction comment eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_instruction_0=label_decl instruction comment eol
+ var n3 = parser.pop.as(Neol)
+ var n2 = parser.pop.as(Ncomment)
+ var n1 = parser.pop.as(Ninstruction)
+ var n0 = parser.pop.as(Nlabel_decl)
+ var p1 = new Nline_instruction(n0, n1, n2, n3)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State label_decl directive comment eol
+private class LRStatelabel_decl_32ddirective_32dcomment_32deol
+ super LRState
+ redef fun to_s do return "label_decl directive comment eol"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE line::line_directive_0=label_decl directive comment eol
+ var n3 = parser.pop.as(Neol)
+ var n2 = parser.pop.as(Ncomment)
+ var n1 = parser.pop.as(Ndirective)
+ var n0 = parser.pop.as(Nlabel_decl)
+ var p1 = new Nline_directive(n0, n1, n2, n3)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Nline)
+ end
+end
+# State id value comma id
+private class LRStateid_32dvalue_32dcomma_32did
+ super LRState
+ redef fun to_s do return "id value comma id"
+ redef fun error_msg do return ""
+ redef fun action(parser) do
+ # REDUCE operand::operand_any=value comma id
+ var n2 = parser.pop.as(Nid)
+ var n1 = parser.pop.as(Ncomma)
+ var n0 = parser.pop.as(Nvalue)
+ var p1 = new Noperand_any(n0, n1, n2)
+ var prod = p1
+ parser.node_stack.push prod
+ parser.goto(goto_Noperand)
+ end
+end
--- /dev/null
+# Generated by nitcc for the language pep8
+import nitcc_runtime
+import pep8_lexer
+import pep8_parser
+class MyTest
+ super TestParser
+ redef fun name do return "pep8"
+ redef fun new_lexer(text) do return new MyLexer(text)
+ redef fun new_parser do return new MyParser
+end
+var t = new MyTest
+t.main
--- /dev/null
+#!/usr/bin/perl -w
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+# Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# prescc, a Sablecc preprocessor.
+#
+# Synopsis
+#
+# Extends a sablecc grammar with parametrized productions and other syntactic stuff.
+#
+# Description
+#
+# A production named foo~bar~baz semantically correspond to a production foo with two boolean parameters bar and baz
+# In fact foo is a family of 4 distinct productions: foo, foo_bar, foo_baz and foo_bar_baz
+# In a parametrized production with a parameter ~xxx:
+# * parameters (~xxx) are substituted with _xxx if the parameter is true and removed if the parameter is false
+# * guarded alternatives (!xxx) are disabled if the parameter is true
+#
+# Limitations
+#
+# prescc is badly implemented in perl and is not robust.
+# Users must remember the following:
+# * parametrized productions MUST be terminated with a line containing only a single semicolon (;)
+# * parameters (~) and guards (!) in alternatives MUST correspond to a parameter of the enclosing production
+# * if required, names in transformations MUST contain the full invocation name (with all parameters)
+# foo bar_x~y~z_t baz {-> New p(foo, bar_x~y~z_t.q)}
+# * guards do not understand grammar, they just remove the whole line
+# * The AST MUST start with a line containing only "Abstract Syntax Tree"
+#
+# Example of the dangling else implementation:
+#
+# stmt~withelse =
+# 'if' expr 'then' stmt_withelse 'else' stmt~withelse |
+# !withelse 'if' expr 'then' stmt |
+# nop
+# ;
+
+while (<>) {
+ push @lines, $_;
+}
+$lines = join "", @lines;
+
+$current = "";
+for (@lines) {
+ if (/^.*{\s*->\s*(\w+)\s*}/) {
+ $current = $1;
+ }
+ $current = "" if /;/;
+ next if ($current eq "");
+ if (s/{\:(\w+)}/{$1}/) {
+ $alt = $1;
+ @newargs = ();
+ while (/((\[(\w*)\])?:)?([\w~]+)(})?/g) {
+ $id=defined $3?$3:$4;
+ next if ((defined $1) && !(defined $3));
+ next if (defined $5);
+ $4 =~ /([a-z]+)/;
+ $argalt = $1;
+ if ($id eq $argalt) {
+ push @newargs, "$id";
+ } else {
+ push @newargs, "$id.$argalt";
+ }
+ }
+ chomp;
+ $_ .= " {-> New $current.$alt(". join(", ", @newargs) .")}\n";
+ s/([^\]])\:(\w+)/$1$2/g;
+ }
+}
+
+# List all the available parameters in the extended grammar
+@params = ();
+while ($lines =~ /\~([a-zA-Z]+)/g) {
+ if (!$found{$1}) {
+ push @params, $1;
+ $found{$1}=1;
+ }
+}
+
+$ast = "Abstract Syntax Tree";
+@res = ();
+for $token (@params) {
+ print STDERR "Parameter ~$token\n";
+ #push @res, "//Start part $token\n";
+# first, sed starts from first line to the AST line and removes ~xxx and !xxx
+ for $l (@lines) {
+ $_ = $l;
+ last if (/^$ast/);
+ s/[~!]$token//g;
+ push @res, $_;
+ }
+ #push @res, "//Generated part $token\n";
+ # second, sed clones ~xxx parametrized productions, substitute ~xxx with _xxx and delete !xxx lines
+ $into = 0;
+ for $l (@lines) {
+ $_ = $l;
+ $into = 1 if (/~$token/);
+ next if (!$into);
+ s/~$token/_$token/g;
+ next if /!$token/;
+ push @res, $_;
+ $into = 0 if (/;/);
+ }
+ #push @res, "//End of generated part $token\n";
+
+ # third, sed continues fron AST line to last line and remove ~xxx and !xxx
+ $into = 0;
+ for (@lines) {
+ $into = 1 if (/^$ast/);
+ next if (!$into);
+ push @res, $_;
+ }
+ #push @res, "//End part $token\n";
+ @lines = @res;
+ @res = ();
+}
+print "/* This file is autogenerated, do not modify it */";
+print (join "", @lines);
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+# Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# prescc, a Sablecc preprocessor.
+#
+# Synopsis
+#
+# Extends a sablecc grammar with parametrized productions.
+#
+# Description
+#
+# A production named foo~bar~baz semantically correspond to a production foo with two boolean parameters bar and baz
+# In fact foo is a family of 4 distinct productions: foo, foo_bar, foo_baz and foo_bar_baz
+# In a parametrized production with a parameter ~xxx:
+# * parameters (~xxx) are substituted with _xxx if the parameter is true and removed if the parameter is false
+# * guarded alternatives (!xxx) are disabled if the parameter is true
+#
+# Limitations
+#
+# prescc is badly implemented with shell, sed and perl and is not robust.
+# Users must remember the following:
+# * parametrized productions MUST be terminated with a line containing only a single semicolon (;)
+# * parameters (~) and guards (!) in alternatives MUST correspond to a parameter of the enclosing production
+# * if required, names in transformations MUST contain the full invocation name (with all parameters)
+# foo bar_x~y~z_t baz {-> New p(foo, bar_x~y~z_t.q)}
+# * guards do not understand grammar, they just remove the whole line
+# * The AST MUST start with a line containing only "Abstract Syntax Tree"
+#
+# Example of the dangling else implementation:
+#
+# stmt~withelse =
+# 'if' expr 'then' stmt_withelse 'else' stmt~withelse |
+# !withelse 'if' expr 'then' stmt |
+# nop
+# ;
+
+
+case $# in
+ 2);;
+ *) echo "Usage: prescc infile outfile"; exit
+esac
+
+
+infile=$1
+outfile=$2
+tmpfile=`mktemp "$2.XXXXXX"`
+
+printf "/* This file is autogenerated, do not modify it */" > "$outfile"
+cat "$infile" >> "$outfile"
+
+# The perl code is used to list all the available parameters in the extended grammar
+for token in `perl -ne 'while (/\~([a-zA-Z]+)/g) {if (!$found{$1}) {print "$1\n"; $found{$1}=1}}' "$infile"`
+do
+ echo "Parameter ~$token"
+ # first, sed starts from first line to the AST line and removes ~xxx and !xxx
+ sed -n -e "
+ 1,/^Abstract Syntax Tree/{
+ /^Abstract Syntax Tree/b
+ s/[\~!]$token//g
+ p
+ }
+ " "$outfile" > "$tmpfile"
+ # second, sed clones ~xxx parametrized productions, substitute ~xxx with _xxx and delete !xxx lines
+ sed -n -e "
+ /\~$token/,/;/{
+ s/\~$token/_$token/g
+ /!$token/d
+ p
+ }
+ " "$outfile" >> "$tmpfile"
+ # third, sed continues fron AST line to last line and remove ~xxx and !xxx
+ sed -n -e "
+ /^Abstract Syntax Tree/,\${
+ s/[\~!]$token//g
+ p
+ }
+ " "$outfile" >> "$tmpfile"
+ mv "$tmpfile" "$outfile"
+done
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Module that interfaces the parsing tables.
+module tables
+
+# Interface allowing the acces of the tables used during the parsing.
+interface TablesCapable
+ # The goto value of the lexer at row i, column j-1
+ # Note that the length of the row r is stored at (r, 0)
+ fun lexer_goto(i, j: Int): Int is extern "lexer_goto"
+
+ # The accept value of the lexer at i
+ fun lexer_accept(i: Int): Int is extern "lexer_accept"
+
+ # The goto value of the parser at row i, column j-1
+ # Note that the length of the row r is stored at (r, 0)
+ fun parser_goto(i, j: Int): Int is extern "parser_goto"
+
+ # The action value of the parser at row i, column j-1
+ # Note that the length of the row r is stored at (r, 0)
+ fun parser_action(i, j: Int): Int is extern "parser_action"
+end
--- /dev/null
+$ // This file is part of NIT ( http://www.nitlanguage.org ).
+$ //
+$ // Copyright 2008 Jean Privat <jean@pryen.org>
+$ // Based on algorithms developped for ( http://www.sablecc.org/ ).
+$ //
+$ // Licensed under the Apache License, Version 2.0 (the "License");
+$ // you may not use this file except in compliance with the License.
+$ // You may obtain a copy of the License at
+$ //
+$ // http://www.apache.org/licenses/LICENSE-2.0
+$ //
+$ // Unless required by applicable law or agreed to in writing, software
+$ // distributed under the License is distributed on an "AS IS" BASIS,
+$ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+$ // See the License for the specific language governing permissions and
+$ // limitations under the License.
+
+$ template make_lexer()
+
+# The lexer extract NIT tokens from an input stream.
+# It is better user with the Parser
+class Lexer
+ super TablesCapable
+ # Last peeked token
+ var _token: nullable Token
+
+ # Lexer current state
+ var _state: Int = 0
+
+ # The source file
+ readable var _file: SourceFile
+
+ # Current character in the stream
+ var _stream_pos: Int = 0
+
+ # Current line number in the input stream
+ var _line: Int = 0
+
+ # Current column in the input stream
+ var _pos: Int = 0
+
+ # Was the last character a cariage-return?
+ var _cr: Bool = false
+
+$ foreach {lexer_data/state}
+ # Constante state values
+ private fun state_${translate(@name,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}: Int do return @id end
+$ end foreach
+
+ # Create a new lexer for a stream (and a name)
+ init(file: SourceFile)
+ do
+ _file = file
+ end
+
+ # The last peeked token to chain them
+ private var last_token: nullable Token = null
+
+ # Give the next token (but do not consume it)
+ fun peek: Token
+ do
+ var t = _token
+ if t != null then return t
+
+ t = get_token
+ while t == null do t = get_token
+
+ var l = last_token
+ if l != null then
+ l.next_token = t
+ t.prev_token = l
+ end
+
+ last_token = t
+ _token = t
+ return t
+ end
+
+ # Give and consume the next token
+ fun next: Token
+ do
+ var result = peek
+ _token = null
+ return result
+ end
+
+ # Primitive method to return a token, or return null if it is discarded
+ # Is used to implement `peek` and `next`
+ protected fun get_token: nullable Token
+ do
+ var dfa_state = 0
+
+ var sp = _stream_pos
+ var start_stream_pos = sp
+ var start_pos = _pos
+ var start_line = _line
+ var string = _file.string
+ var string_len = string.length
+
+ var accept_state = -1
+ var accept_token = -1
+ var accept_length = -1
+ var accept_pos = -1
+ var accept_line = -1
+
+ loop
+ if sp >= string_len then
+ dfa_state = -1
+ else
+ var c = string[sp].ascii
+ sp += 1
+
+ var cr = _cr
+ var line = _line
+ var pos = _pos
+ if c == 10 then
+ if cr then
+ cr = false
+ _file.line_starts[line] = sp
+ else
+ line = line + 1
+ pos = 0
+ _file.line_starts[line] = sp
+ end
+ else if c == 13 then
+ line = line + 1
+ pos = 0
+ cr = true
+ _file.line_starts[line] = sp
+ else
+ pos = pos + 1
+ cr = false
+ end
+
+ loop
+ var old_state = dfa_state
+ if dfa_state < -1 then
+ old_state = -2 - dfa_state
+ end
+
+ dfa_state = -1
+
+ var low = 0
+ var high = lexer_goto(old_state, 0) - 1
+
+ if high >= 0 then
+ while low <= high do
+ var middle = (low + high) / 2
+ var offset = middle * 3 + 1 # +1 because length is at 0
+
+ if c < lexer_goto(old_state, offset) then
+ high = middle - 1
+ else if c > lexer_goto(old_state, offset+1) then
+ low = middle + 1
+ else
+ dfa_state = lexer_goto(old_state, offset+2)
+ break
+ end
+ end
+ end
+ if dfa_state > -2 then break
+ end
+
+ _cr = cr
+ _line = line
+ _pos = pos
+ end
+
+ if dfa_state >= 0 then
+ var tok = lexer_accept(dfa_state)
+ if tok != -1 then
+ accept_state = dfa_state
+ accept_token = tok
+ accept_length = sp - start_stream_pos
+ accept_pos = _pos
+ accept_line = _line
+ end
+ else
+ if accept_state != -1 then
+ var location = new Location(_file, start_line + 1, accept_line + 1, start_pos + 1, accept_pos)
+ _pos = accept_pos
+ _line = accept_line
+ _stream_pos = start_stream_pos + accept_length
+$ foreach {//token}
+ if accept_token == ${position()-1} then
+$ if {count(transition[@from!=@to])!=0}
+ var state_id = _state
+$ foreach transition in {transition[@from!=@to]}
+ if state_id == ${/parser/lexer_data/state[@name=$transition/@from]/@id} then
+ _state = state_${translate(@to,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}
+ end
+$ end
+$ end if
+$ if {@parser_index}
+ return new @ename.init_tk(location)
+$ else
+ return null
+$ end
+ end
+$ end foreach
+ else
+ _stream_pos = sp
+ var location = new Location(_file, start_line + 1, start_line + 1, start_pos + 1, start_pos + 1)
+ if sp > start_stream_pos then
+ var text = string.substring(start_stream_pos, sp-start_stream_pos)
+ var token = new PLexerError.init_lexer_error("Syntax error: unknown token {text}.", location, text)
+ return token
+ else
+ var token = new EOF.init_tk(location)
+ return token
+ end
+ end
+ end
+ end
+ end
+end
+
+$ end template
+
+
+
+$ template make_lexer_table()
+$ foreach {lexer_data/goto_table/state}
+$ foreach {row}
+$ if {count(goto)!=0}
+static const int lexer_goto_row${position()}[] = {
+ ${count(goto)},
+$ foreach {goto}
+ @low, @high, @state[-sep ','-]
+$ end foreach
+};
+$ end
+$ end foreach
+static const int lexer_goto_row_null[] = {0};
+const int* const lexer_goto_table[] = {
+$ foreach {row}
+$ if {count(goto)!=0}
+ lexer_goto_row${position()}[-sep ','-]
+$ else
+ lexer_goto_row_null[-sep ','-]
+$ end
+$ end foreach
+};
+$ end foreach
+
+$ foreach {lexer_data/accept_table/state}
+const int lexer_accept_table[] = {
+ [-foreach {i}-]${.}[-sep ','-][-end foreach-]
+};
+$ end foreach
+
+$ end template
--- /dev/null
+$ // This file is part of NIT ( http://www.nitlanguage.org ).
+$ //
+$ // Copyright 2008 Jean Privat <jean@pryen.org>
+$ // Based on algorithms developped for ( http://www.sablecc.org/ ).
+$ //
+$ // Licensed under the Apache License, Version 2.0 (the "License");
+$ // you may not use this file except in compliance with the License.
+$ // You may obtain a copy of the License at
+$ //
+$ // http://www.apache.org/licenses/LICENSE-2.0
+$ //
+$ // Unless required by applicable law or agreed to in writing, software
+$ // distributed under the License is distributed on an "AS IS" BASIS,
+$ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+$ // See the License for the specific language governing permissions and
+$ // limitations under the License.
+
+$ include 'lexer.xss'
+$ include 'parser.xss'
+$ include 'tokens.xss'
+$ include 'prods.xss'
+
+$ output 'parser_abs.nit'
+# Raw AST node hierarchy.
+# This file was generated by SableCC (http://www.sablecc.org/).
+module parser_abs
+
+import location
+
+$ call make_abs_tokens()
+$ call make_abs_prods()
+$ end output
+
+$ output 'lexer.nit'
+# Lexer and its tokens.
+# This file was generated by SableCC (http://www.sablecc.org/).
+module lexer
+
+$ if $usermodule
+intrude import $usermodule
+$ else
+intrude import parser_abs
+$ end
+private import tables
+$ call make_tokens()
+$ call make_lexer()
+$ end output
+
+$ output 'parser_prod.nit'
+# Production AST nodes full definition.
+# This file was generated by SableCC (http://www.sablecc.org/).
+module parser_prod
+
+import lexer
+$ if $usermodule
+intrude import $usermodule
+$ else
+intrude import parser_abs
+$ end
+private import tables
+
+$ call make_prods()
+$ end output
+
+$ output 'parser.nit'
+# Parser.
+# This file was generated by SableCC (http://www.sablecc.org/).
+module parser
+
+intrude import parser_prod
+import tables
+$ call make_parser()
+$ end output
+
+$ output 'tables_nit.c'
+/* This file was generated by SableCC (http://www.sablecc.org/). */
+#include <stdlib.h>
+#include "tables_nit.h"
+
+$ call make_lexer_table()
+$ call make_parser_table()
+$ end output
--- /dev/null
+$ // This file is part of NIT ( http://www.nitlanguage.org ).
+$ //
+$ // Copyright 2008 Jean Privat <jean@pryen.org>
+$ // Based on algorithms developped for ( http://www.sablecc.org/ ).
+$ //
+$ // Licensed under the Apache License, Version 2.0 (the "License");
+$ // you may not use this file except in compliance with the License.
+$ // You may obtain a copy of the License at
+$ //
+$ // http://www.apache.org/licenses/LICENSE-2.0
+$ //
+$ // Unless required by applicable law or agreed to in writing, software
+$ // distributed under the License is distributed on an "AS IS" BASIS,
+$ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+$ // See the License for the specific language governing permissions and
+$ // limitations under the License.
+
+$ template make_parser()
+
+# State of the parser automata as stored in the parser stack.
+private class State
+ # The internal state number
+ readable writable var _state: Int
+
+ # The node stored with the state in the stack
+ readable writable var _nodes: nullable Object
+
+ init(state: Int, nodes: nullable Object)
+ do
+ _state = state
+ _nodes = nodes
+ end
+end
+
+class Parser
+ super TablesCapable
+ # Associated lexer
+ var _lexer: Lexer
+
+ # Stack of pushed states and productions
+ var _stack: Array[State]
+
+ # Position in the stack
+ var _stack_pos: Int
+
+ # Create a new parser based on a given lexer
+ init(lexer: Lexer)
+ do
+ _lexer = lexer
+ _stack = new Array[State]
+ _stack_pos = -1
+ build_reduce_table
+ end
+
+ # Do a transition in the automata
+ private fun go_to(index: Int): Int
+ do
+ var state = state
+ var low = 1
+ var high = parser_goto(index, 0) - 1
+
+ while low <= high do
+ var middle = (low + high) / 2
+ var subindex = middle * 2 + 1 # +1 because parser_goto(index, 0) is the length
+
+ var goal = parser_goto(index, subindex)
+ if state < goal then
+ high = middle - 1
+ else if state > goal then
+ low = middle + 1
+ else
+ return parser_goto(index, subindex+1)
+ end
+ end
+
+ return parser_goto(index, 2) # Default value
+ end
+
+ # Push someting in the state stack
+ private fun push(numstate: Int, list_node: nullable Object)
+ do
+ var pos = _stack_pos + 1
+ _stack_pos = pos
+ if pos < _stack.length then
+ var state = _stack[pos]
+ state.state = numstate
+ state.nodes = list_node
+ else
+ _stack.push(new State(numstate, list_node))
+ end
+ end
+
+ # The current state
+ private fun state: Int
+ do
+ return _stack[_stack_pos].state
+ end
+
+ # Pop something from the stack state
+ private fun pop: nullable Object
+ do
+ var res = _stack[_stack_pos].nodes
+ _stack_pos = _stack_pos -1
+ return res
+ end
+
+ # Build and return a full AST.
+ fun parse: Start
+ do
+ push(0, null)
+
+ var lexer = _lexer
+ loop
+ var token = lexer.peek
+ if token isa PError then
+ return new Start(null, token)
+ end
+
+ var state = self.state
+ var index = token.parser_index
+ var action_type = parser_action(state, 2)
+ var action_value = parser_action(state, 3)
+
+ var low = 1
+ var high = parser_action(state, 0) - 1
+
+ while low <= high do
+ var middle = (low + high) / 2
+ var subindex = middle * 3 + 1 # +1 because parser_action(state, 0) is the length
+
+ var goal = parser_action(state, subindex)
+ if index < goal then
+ high = middle - 1
+ else if index > goal then
+ low = middle + 1
+ else
+ action_type = parser_action(state, subindex+1)
+ action_value = parser_action(state, subindex+2)
+ break
+ end
+ end
+
+ if action_type == 0 then # SHIFT
+ push(action_value, lexer.next)
+ else if action_type == 1 then # REDUCE
+ _reduce_table[action_value].action(self)
+ else if action_type == 2 then # ACCEPT
+ var node2 = lexer.next
+ assert node2 isa EOF
+ var node1 = pop
+ assert node1 isa ${/parser/prods/prod/@ename}
+ var node = new Start(node1, node2)
+ (new ComputeProdLocationVisitor).enter_visit(node)
+ return node
+ else if action_type == 3 then # ERROR
+ var node2 = new PParserError.init_parser_error("Syntax error: unexpected {token}.", token.location, token)
+ var node = new Start(null, node2)
+ return node
+ end
+ end
+ end
+
+ var _reduce_table: Array[ReduceAction]
+ private fun build_reduce_table
+ do
+ _reduce_table = new Array[ReduceAction].with_items(
+$ foreach {rules/rule}
+ new ReduceAction@index(@leftside)[-sep ','-]
+$ end foreach
+ )
+ end
+end
+
+redef class Prod
+ # Location on the first token after the start of a production
+ # So outside the production for epilon production
+ var _first_location: nullable Location
+end
+
+# Find location of production nodes
+# Uses existing token locations to infer location of productions.
+private class ComputeProdLocationVisitor
+ super Visitor
+ # Currenlty visited productions that need a first token
+ var _need_first_prods: Array[Prod] = new Array[Prod]
+
+ # Already visited epsilon productions that waits something after them
+ var _need_after_epsilons: Array[Prod] = new Array[Prod]
+
+ # Location of the last visited token in the current production
+ var _last_location: nullable Location = null
+
+ redef fun visit(n: ANode)
+ do
+ if n isa Token then
+ var loc = n.location
+ _last_location = loc
+
+ # Add a first token to productions that need one
+ if not _need_first_prods.is_empty then
+ for no in _need_first_prods do
+ no._first_location = loc
+ end
+ _need_first_prods.clear
+ end
+
+ # Find location for already visited epsilon production that need one
+ if not _need_after_epsilons.is_empty then
+ var loco = new Location(loc.file, loc.line_start, loc.line_start, loc.column_start, loc.column_start)
+ for no in _need_after_epsilons do
+ no.location = loco
+ end
+ _need_after_epsilons.clear
+ end
+ else
+ assert n isa Prod
+ _need_first_prods.add(n)
+
+ n.visit_all(self)
+
+ var startl = n._first_location
+ if startl != null then
+ # Non-epsilon production
+ var endl = _last_location
+ assert endl != null
+
+ n.location = new Location(startl.file, startl.line_start, endl.line_end, startl.column_start, endl.column_end)
+
+ if not _need_after_epsilons.is_empty then
+ var loc = new Location(endl.file, endl.line_end, endl.line_end, endl.column_end, endl.column_end)
+ for no in _need_after_epsilons do
+ # Epsilon production that finishes the current non-epsilon production
+ no.location = loc
+ end
+ _need_after_epsilons.clear
+ end
+ else
+ # Epsilon production in the middle or that finishes a parent non-epsilon production
+ _need_after_epsilons.add(n)
+ end
+ end
+ end
+
+ init do end
+end
+
+# Each reduca action has its own class, this one is the root of the hierarchy.
+private abstract class ReduceAction
+ fun action(p: Parser) is abstract
+ fun concat(l1, l2 : Array[Object]): Array[Object]
+ do
+ if l1.is_empty then return l2
+ l1.append(l2)
+ return l1
+ end
+ var _goto: Int
+ init(g: Int) do _goto = g
+end
+
+$ foreach {rules/rule}
+private class ReduceAction@index
+ super ReduceAction
+ redef fun action(p: Parser)
+ do
+ var node_list: nullable Object = null
+$ foreach {action}
+$ choose
+$ when {@cmd='POP'}
+ var ${translate(@result,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} = p.pop
+$ end
+$ when {@cmd='FETCHLIST'}
+ var ${translate(@result,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} = ${translate(@from,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}
+ assert ${translate(@result,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} isa Array[Object]
+$ end
+$ when {@cmd='FETCHNODE'}
+ var ${translate(@result,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} = ${translate(@from,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}
+ assert ${translate(@result,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} isa nullable @etype
+$ end
+$ when {@cmd='ADDNODE'}
+ if ${translate(@node,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} != null then
+ ${translate(@tolist,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}.add(${translate(@node,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")})
+ end
+$ end
+$ when {@cmd='ADDLIST'}
+ ${translate(@tolist,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} = concat(${translate(@tolist,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}, ${translate(@fromlist,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")})
+$ end
+$ when {@cmd='MAKELIST'}
+ var ${translate(@result,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} = new Array[Object]
+$ end
+$ when {@cmd='MAKENODE'}
+$ if {count(arg)!=0}
+ var ${translate(@result,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}: nullable @etype = new @etype.init_${translate(@etype,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}(
+$ foreach {arg}
+$ if @null
+ null[-sep ','-]
+$ else
+ ${translate(.,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}[-sep ','-]
+$ end
+$ end foreach
+ )
+$ else
+ var ${translate(@result,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}: nullable @etype = new @etype.init_${translate(@etype,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}
+$ end
+$ end
+$ when {@cmd='RETURNNODE'}
+$ if @null
+ node_list = null
+$ else
+ node_list = ${translate(@node,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}
+$ end
+$ end
+$ when {@cmd='RETURNLIST'}
+ node_list = ${translate(@list,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}
+$ end
+$ end choose
+$ end foreach
+ p.push(p.go_to(_goto), node_list)
+ end
+end
+$ end foreach
+$ end template
+
+$ template make_parser_table()
+$ foreach {parser_data/action_table/row}
+static int parser_action_row${position()}[] = {
+ ${count(action)},
+$ foreach {action}
+ @from, @action, @to[-sep ','-]
+$ end foreach
+};
+$ end foreach
+
+const int* const parser_action_table[] = {
+$ foreach {parser_data/action_table/row}
+ parser_action_row${position()}[-sep ','-]
+$ end foreach
+};
+
+$ foreach {parser_data/goto_table/row}
+static int parser_goto_row${position()}[] = {
+ ${count(goto)},
+$ foreach {goto}
+ @from, @to[-sep ','-]
+$ end foreach
+};
+$ end foreach
+
+const int* const parser_goto_table[] = {
+$ foreach {parser_data/goto_table/row}
+ parser_goto_row${position()}[-sep ','-]
+$ end foreach
+};
+$ end template
--- /dev/null
+$ // This file is part of NIT ( http://www.nitlanguage.org ).
+$ //
+$ // Copyright 2008 Jean Privat <jean@pryen.org>
+$ // Based on algorithms developped for ( http://www.sablecc.org/ ).
+$ //
+$ // Licensed under the Apache License, Version 2.0 (the "License");
+$ // you may not use this file except in compliance with the License.
+$ // You may obtain a copy of the License at
+$ //
+$ // http://www.apache.org/licenses/LICENSE-2.0
+$ //
+$ // Unless required by applicable law or agreed to in writing, software
+$ // distributed under the License is distributed on an "AS IS" BASIS,
+$ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+$ // See the License for the specific language governing permissions and
+$ // limitations under the License.
+
+$ template make_abs_prods()
+$ set baseprod = {//prod/@ename}
+
+$ foreach {//prod}
+class @ename super Prod end
+$ end
+
+$ foreach {//alt}
+class @ename
+ super ${../@ename}
+$ foreach {elem}
+$ if @is_list
+ readable var _n_@name: List[@etype] = new List[@etype]
+$ else
+$ if @modifier
+ readable var _n_@name: nullable @etype = null
+$ else
+ readable var _n_@name: @etype
+$ end
+$ end
+$ end
+end
+$ end
+
+class Start
+ super Prod
+ readable var _n_base: nullable $baseprod
+ readable var _n_eof: EOF
+ init(
+ n_base: nullable $baseprod,
+ n_eof: EOF)
+ do
+ _n_base = n_base
+ _n_eof = n_eof
+ end
+
+end
+$ end template
+
+$ template make_prods()
+$ set baseprod = {//prod/@ename}
+$ foreach {//alt}
+redef class @ename
+ private init empty_init do end
+
+$ if {count(elem)!=0}
+ init init_${translate(@ename,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")} (
+$ foreach {elem}
+$ if {@is_list}
+ n_@{name}: Collection[Object][-sep ','-] # Should be Collection[@etype]
+$ else
+ n_@{name}: nullable @etype[-sep ','-]
+$ end
+$ end
+ )
+$ else
+ init init_${translate(@ename,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")}
+$ end
+ do
+ empty_init
+$ foreach {elem}
+$ if @is_list
+ for n in n_@{name} do
+ assert n isa @{etype}
+ _n_@{name}.add(n)
+ n.parent = self
+ end
+$ else
+$ if {@modifier}
+ _n_@name = n_@{name}
+ if n_@{name} != null then
+ n_@{name}.parent = self
+ end
+$ else
+ _n_@name = n_@{name}.as(not null)
+ n_@{name}.parent = self
+$ end
+$ end
+$ end
+ end
+
+ redef fun replace_child(old_child: PNode, new_child: nullable PNode)
+ do
+$ foreach {elem}
+$ if @is_list
+ for i in [0.._n_@{name}.length[ do
+ if _n_@{name}[i] == old_child then
+ if new_child != null then
+ assert new_child isa @etype
+ _n_@{name}[i] = new_child
+ new_child.parent = self
+ else
+ _n_@{name}.remove_at(i)
+ end
+ return
+ end
+ end
+$ else
+ if _n_@{name} == old_child then
+ if new_child != null then
+ new_child.parent = self
+ assert new_child isa @etype
+ _n_@{name} = new_child
+ else
+$ if @modifier
+ _n_@{name} = null
+$ else
+ abort
+$ end
+ end
+ return
+ end
+$ end
+$ end foreach
+ end
+
+$ foreach {elem}
+$ if @is_list
+$ else
+ redef fun n_@{name}=(node)
+ do
+ _n_@{name} = node
+$ if @modifier
+ if node != null then
+ node.parent = self
+ end
+$ else
+ node.parent = self
+$ end
+ end
+$ end
+$ end foreach
+
+
+ redef fun visit_all(v: Visitor)
+ do
+$ foreach {elem}
+$ if @is_list
+ for n in _n_@{name} do
+ v.enter_visit(n)
+ end
+$ else
+$ if @modifier
+ if _n_@{name} != null then
+ v.enter_visit(_n_@{name}.as(not null))
+ end
+$ else
+ v.enter_visit(_n_@{name})
+$ end
+$ end
+$ end foreach
+ end
+end
+$ end foreach
+
+redef class Start
+ redef fun replace_child(old_child: PNode, new_child: nullable PNode)
+ do
+ if _n_base == old_child then
+ if new_child == null then
+ else
+ new_child.parent = self
+ assert new_child isa $baseprod
+ _n_base = new_child
+ end
+ old_child.parent = null
+ return
+ end
+ end
+
+ redef fun visit_all(v: Visitor)
+ do
+ if _n_base != null then
+ v.enter_visit(_n_base.as(not null))
+ end
+ v.enter_visit(_n_eof)
+ end
+end
+$ end template
--- /dev/null
+$ // This file is part of NIT ( http://www.nitlanguage.org ).
+$ //
+$ // Copyright 2008 Jean Privat <jean@pryen.org>
+$ // Based on algorithms developped for ( http://www.sablecc.org/ ).
+$ //
+$ // Licensed under the Apache License, Version 2.0 (the "License");
+$ // you may not use this file except in compliance with the License.
+$ // You may obtain a copy of the License at
+$ //
+$ // http://www.apache.org/licenses/LICENSE-2.0
+$ //
+$ // Unless required by applicable law or agreed to in writing, software
+$ // distributed under the License is distributed on an "AS IS" BASIS,
+$ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+$ // See the License for the specific language governing permissions and
+$ // limitations under the License.
+
+$ template make_abs_tokens()
+$ foreach {//token}
+$ if {@parser_index}
+class @ename
+ super Token
+end
+$ end
+$ end
+class EOF
+ super Token
+end
+class PError
+ super EOF
+end
+class PLexerError
+ super PError
+end
+class PParserError
+ super PError
+end
+$ end template
+
+$ template make_tokens()
+
+redef class Token
+ var _text: nullable String
+
+ redef fun text
+ do
+ var res = _text
+ if res != null then return res
+ res = location.text
+ _text = res
+ return res
+ end
+
+ redef fun text=(text)
+ do
+ _text = text
+ end
+
+ fun parser_index: Int is abstract
+end
+
+$ foreach {//token}
+$ if {@parser_index}
+redef class @ename
+ redef fun parser_index: Int
+ do
+ return @parser_index
+ end
+
+ init init_tk(loc: Location)
+ do
+ _location = loc
+ end
+end
+
+$ end if
+$ end foreach
+
+redef class EOF
+ redef fun parser_index: Int
+ do
+ return ${tokens/eof/@parser_index}
+ end
+
+ init init_tk(loc: Location)
+ do
+ _text = ""
+ _location = loc
+ end
+end
+
+redef class PError
+ readable var _message: String
+
+ init init_error(message: String, loc: Location)
+ do
+ init_tk(loc)
+ _message = message
+ end
+end
+
+redef class PLexerError
+ readable var _string: String
+
+ init init_lexer_error(message: String, loc: Location, string: String)
+ do
+ init_error(message, loc)
+ _string = string
+ end
+end
+
+redef class PParserError
+ readable var _token: Token
+
+ init init_parser_error(message: String, loc: Location, token: Token)
+ do
+ init_error(message, loc)
+ _token = token
+ end
+end
+$ end template
--- /dev/null
+module pep8analysis
+
+import backbone
+import ast
+import model
+import cfg
+import flow_analysis
+
+redef class AnalysisManager
+ var opt_help = new OptionBool("Display this help message", "--help","-h")
+ var opt_quiet = new OptionBool("Do not show notes", "--quiet","-q")
+ fun quiet: Bool do return opt_quiet.value
+ fun verbose: Bool do return not opt_quiet.value
+
+ var opt_output = new OptionString("Output directory", "--output", "-o")
+
+ redef init
+ do
+ super
+
+ opts.add_option(opt_help)
+ opts.add_option(opt_quiet)
+ opts.add_option(opt_output)
+ end
+
+ fun run
+ do
+ opts.parse(args)
+ var files = opts.rest
+
+ if files.is_empty or opt_help.value then
+ print "Usage: {sys.program_name} [options] file.pep [other_file.pep [...]]"
+ print "Options:"
+ opts.usage
+ return
+ end
+
+ var dir = opt_output.value
+ if dir == null then dir = "out"
+ if not dir.file_exists then dir.mkdir
+
+ # Parsing
+ for filename in files do
+ reset # noter
+
+ if verbose then print "Analyzing {filename}"
+ if not filename.file_exists then
+ print "Target file \"{filename}\" does not exist."
+ exit 1
+ end
+ var ast = build_ast( filename )
+ assert ast != null
+
+ if failed then continue
+
+ # Build program model
+ var model = build_model(ast)
+
+ if failed then continue
+
+ if model.lines.is_empty then
+ fatal_error( ast, "This programs appears empty" )
+ continue
+ end
+
+ # Create CFG
+ var cfg = build_cfg(model)
+
+ if failed then continue
+
+ # Run analyses
+
+ ## Reaching defs
+ do_reaching_defs_analysis(cfg)
+
+ ## Range
+ do_range_analysis(ast, cfg)
+
+ ## Types
+ do_types_analysis(ast, cfg)
+
+ # Print results
+ var of = new OFStream.open("{dir}/{filename.replace("/","-").replace(".pep",".dot")}")
+ cfg.print_dot(of, true)
+ of.close
+ end
+ if not opt_quiet.value then
+ print_notes
+ end
+ end
+end
+
+redef class Object
+ redef fun manager do return once new AnalysisManager
+end
+
+manager.run