summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
221d941)
Signed-off-by: Jean Privat <jean@pryen.org>
private import tables
redef class Token
private import tables
redef class Token
- var _text: nullable String
+ var text_cache: nullable String
if res != null then return res
res = location.text
if res != null then return res
res = location.text
class Lexer
super TablesCapable
# Last peeked token
class Lexer
super TablesCapable
# Last peeked token
- var _token: nullable Token
+ var token: nullable Token
# Current character in the stream
# Current character in the stream
- var _stream_pos: Int = 0
+ var stream_pos: Int = 0
# Current line number in the input stream
# Current line number in the input stream
# Current column in the input stream
# Current column in the input stream
# Was the last character a cariage-return?
# Was the last character a cariage-return?
# Constante state values
private fun state_initial: Int do return 0 end
# Constante state values
private fun state_initial: Int do return 0 end
class Parser
super TablesCapable
# Associated lexer
class Parser
super TablesCapable
# Associated lexer
# Stack of pushed states and productions
# Stack of pushed states and productions
- var _stack: Array[State]
+ private var stack: Array[State]
+ private var stack_pos: Int
# Create a new parser based on a given lexer
init(lexer: Lexer)
# Create a new parser based on a given lexer
init(lexer: Lexer)
- var _reduce_table: Array[ReduceAction]
+ private var reduce_table: Array[ReduceAction]
private fun build_reduce_table
do
private fun build_reduce_table
do
- _reduce_table = new Array[ReduceAction].with_items(
+ reduce_table = new Array[ReduceAction].with_items(
new ReduceAction0(0),
new ReduceAction1(0),
new ReduceAction2(0),
new ReduceAction0(0),
new ReduceAction1(0),
new ReduceAction2(0),
redef class Prod
# Location on the first token after the start of a production
# So outside the production for epilon production
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
+ var first_location: nullable Location
# Location of the last token before the end of a production
# So outside the production for epilon production
# Location of the last token before the end of a production
# So outside the production for epilon production
- var _last_location: nullable Location
+ var last_location: nullable Location
end
# Find location of production nodes
end
# Find location of production nodes
private class ComputeProdLocationVisitor
super Visitor
# Currenlty visited productions that need a first token
private class ComputeProdLocationVisitor
super Visitor
# Currenlty visited productions that need a first token
- var _need_first_prods: Array[Prod] = new Array[Prod]
+ var need_first_prods: Array[Prod] = new Array[Prod]
# Already visited epsilon productions that waits something after them
# Already visited epsilon productions that waits something after them
- var _need_after_epsilons: Array[Prod] = new Array[Prod]
+ var need_after_epsilons: Array[Prod] = new Array[Prod]
# Already visited epsilon production that waits something before them
# Already visited epsilon production that waits something before them
- var _need_before_epsilons: Array[Prod] = new Array[Prod]
+ var need_before_epsilons: Array[Prod] = new Array[Prod]
# Location of the last visited token in the current production
# Location of the last visited token in the current production
- var _last_location: nullable Location = null
+ var last_location: nullable Location = null
redef fun visit(n: nullable ANode)
do
redef fun visit(n: nullable ANode)
do
l1.append(l2)
return l1
end
l1.append(l2)
return l1
end
init(g: Int) do _goto = g
end
init(g: Int) do _goto = g
end
# Raw AST node hierarchy.
# This file was generated by SableCC (http://www.sablecc.org/).
# Raw AST node hierarchy.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_nodes is old_style_init
import location
# Root of the AST hierarchy
abstract class ANode
import location
# Root of the AST hierarchy
abstract class ANode
- var _location: nullable Location = null
-
# Location is set during AST building. Once built, location cannon be null
# However, manual instanciated nodes may need mode care
# 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)
+ var location: Location is writable, noinit
end
# Ancestor of all tokens
end
# Ancestor of all tokens
# Ancestor of all productions
abstract class Prod
super ANode
# Ancestor of all productions
abstract class Prod
super ANode
- fun location=(loc: Location) do _location = loc
end
class TEol
super Token
end
class TEol
super Token
end
class EOF
super Token
end
class EOF
super Token
- #private init noinit do end
end
class AError
super EOF
end
class AError
super EOF
- #private init noinit do end
end
class ALine
super Prod
end
class ALine
super Prod
- var _n_label_decl: nullable ALabelDecl = null
- fun n_label_decl: nullable ALabelDecl do return _n_label_decl
- var _n_comment: nullable TComment = null
- fun n_comment: nullable TComment do return _n_comment
+ var n_label_decl: nullable ALabelDecl = null
+ var n_comment: nullable TComment = null
end
class AInstruction
super Prod
end
class AInstruction
super Prod
- var _n_id: TId
- fun n_id: TId do return _n_id
- fun n_id=(n_id: TId) do _n_id = n_id
- init do end
+ var n_id: TId is noinit
end
class AOperand
super Prod
end
class AOperand
super Prod
- var _n_value: AValue
- fun n_value: AValue do return _n_value
- init do end
+ var n_value: AValue is noinit
end
class AValue super Prod end
class ADirective super Prod end
class AListing
super Prod
end
class AValue super Prod end
class ADirective super Prod end
class AListing
super Prod
- var _n_lines: List[ALine] = new List[ALine]
- fun n_lines: List[ALine] do return _n_lines
- var _n_label_decl: nullable ALabelDecl = null
- fun n_label_decl: nullable ALabelDecl do return _n_label_decl
- var _n_end_block: TEndBlock
- fun n_end_block: TEndBlock do return _n_end_block
- init do end
+ var n_lines: List[ALine] = new List[ALine]
+ var n_label_decl: nullable ALabelDecl = null
+ var n_end_block: TEndBlock is noinit
end
class AEmptyLine
super ALine
end
class AEmptyLine
super ALine
- var _n_eol: TEol
- fun n_eol: TEol do return _n_eol
- init do end
+ var n_eol: TEol is noinit
end
abstract class ANonEmptyLine
super ALine
end
class AInstructionLine
super ANonEmptyLine
end
abstract class ANonEmptyLine
super ALine
end
class AInstructionLine
super ANonEmptyLine
- var _n_instruction: AInstruction
- fun n_instruction: AInstruction do return _n_instruction
- var _n_eol: TEol
- fun n_eol: TEol do return _n_eol
- init do end
+ var n_instruction: AInstruction is noinit
+ var n_eol: TEol is noinit
end
class ADirectiveLine
super ANonEmptyLine
end
class ADirectiveLine
super ANonEmptyLine
- var _n_directive: ADirective
- fun n_directive: ADirective do return _n_directive
- var _n_eol: TEol
- fun n_eol: TEol do return _n_eol
- init do end
+ var n_directive: ADirective is noinit
+ var n_eol: TEol is noinit
end
class ALabelDecl
super Prod
end
class ALabelDecl
super Prod
- var _n_id: TId
- fun n_id: TId do return _n_id
- var _n_colon: TColon
- fun n_colon: TColon do return _n_colon
- init do end
+ var n_id: TId is noinit
+ var n_colon: TColon is noinit
end
class AUnaryInstruction
super AInstruction
end
class ABinaryInstruction
super AInstruction
end
class AUnaryInstruction
super AInstruction
end
class ABinaryInstruction
super AInstruction
- var _n_operand: AOperand
- fun n_operand: AOperand do return _n_operand
- init do end
+ var n_operand: AOperand is noinit
end
class AImmediateOperand
super AOperand
end
class AAnyOperand
super AOperand
end
class AImmediateOperand
super AOperand
end
class AAnyOperand
super AOperand
- var _n_comma: TComma
- fun n_comma: TComma do return _n_comma
- var _n_id: TId
- fun n_id: TId do return _n_id
- init do end
+ var n_comma: TComma is noinit
+ var n_id: TId is noinit
end
class ALabelValue
super AValue
end
class ALabelValue
super AValue
- var _n_id: TId
- fun n_id: TId do return _n_id
- init do end
+ var n_id: TId is noinit
end
class ANumberValue
super AValue
end
class ANumberValue
super AValue
- var _n_number: TNumber
- fun n_number: TNumber do return _n_number
- init do end
+ var n_number: TNumber is noinit
end
class ACharValue
super AValue
end
class ACharValue
super AValue
- var _n_char: TChar
- fun n_char: TChar do return _n_char
- init do end
+ var n_char: TChar is noinit
end
class AStringValue
super AValue
end
class AStringValue
super AValue
- var _n_string: TString
- fun n_string: TString do return _n_string
- init do end
+ var n_string: TString is noinit
end
class AHexValue
super AValue
end
class AHexValue
super AValue
- var _n_hex: THex
- fun n_hex: THex do return _n_hex
- init do end
+ var n_hex: THex is noinit
end
class AByteDirective
super ADirective
end
class AByteDirective
super ADirective
- var _n_tk_byte: TTkByte
- fun n_tk_byte: TTkByte do return _n_tk_byte
- var _n_value: AValue
- fun n_value: AValue do return _n_value
- init do end
+ var n_tk_byte: TTkByte is noinit
+ var n_value: AValue is noinit
end
class AWordDirective
super ADirective
end
class AWordDirective
super ADirective
- var _n_tk_word: TTkWord
- fun n_tk_word: TTkWord do return _n_tk_word
- var _n_value: AValue
- fun n_value: AValue do return _n_value
- init do end
+ var n_tk_word: TTkWord is noinit
+ var n_value: AValue is noinit
end
class ABlockDirective
super ADirective
end
class ABlockDirective
super ADirective
- var _n_tk_block: TTkBlock
- fun n_tk_block: TTkBlock do return _n_tk_block
- var _n_value: AValue
- fun n_value: AValue do return _n_value
- init do end
+ var n_tk_block: TTkBlock is noinit
+ var n_value: AValue is noinit
end
class AAsciiDirective
super ADirective
end
class AAsciiDirective
super ADirective
- var _n_tk_ascii: TTkAscii
- fun n_tk_ascii: TTkAscii do return _n_tk_ascii
- var _n_value: AValue
- fun n_value: AValue do return _n_value
- init do end
+ var n_tk_ascii: TTkAscii is noinit
+ var n_value: AValue is noinit
end
class AAddrssDirective
super ADirective
end
class AAddrssDirective
super ADirective
- var _n_tk_addrss: TTkAddrss
- fun n_tk_addrss: TTkAddrss do return _n_tk_addrss
- var _n_value: AValue
- fun n_value: AValue do return _n_value
- init do end
+ var n_tk_addrss: TTkAddrss is noinit
+ var n_value: AValue is noinit
end
class AEquateDirective
super ADirective
end
class AEquateDirective
super ADirective
- var _n_tk_equate: TTkEquate
- fun n_tk_equate: TTkEquate do return _n_tk_equate
- var _n_value: AValue
- fun n_value: AValue do return _n_value
- init do end
+ var n_tk_equate: TTkEquate is noinit
+ var n_value: AValue is noinit
end
class ABurnDirective
super ADirective
end
class ABurnDirective
super ADirective
- var _n_tk_burn: TTkBurn
- fun n_tk_burn: TTkBurn do return _n_tk_burn
- var _n_value: AValue
- fun n_value: AValue do return _n_value
- init do end
+ var n_tk_burn: TTkBurn is noinit
+ var n_value: AValue is noinit
end
class Start
super Prod
end
class Start
super Prod
- var _n_base: nullable AListing
- fun n_base: nullable AListing do return _n_base
- var _n_eof: EOF
- fun n_eof: EOF do return _n_eof
+ var n_base: nullable AListing
+ var n_eof: EOF is noinit
init(n_base: nullable AListing, n_eof: EOF)
do
super
init(n_base: nullable AListing, n_eof: EOF)
do
super
redef class ANode
# Parent of the node in the AST
redef class ANode
# Parent of the node in the AST
- var _parent: nullable ANode
- fun parent: nullable ANode do return _parent
- fun parent=(p: nullable ANode) do _parent = p
+ var parent: nullable ANode is writable
# Remove a child from the AST
fun remove_child(child: ANode)
# Remove a child from the AST
fun remove_child(child: ANode)
import model
import cfg
import flow_analysis
import model
import cfg
import flow_analysis
+intrude import standard::stream
in "C++" `{
#include <bind.h>
in "C++" `{
#include <bind.h>