Signed-off-by: Jean Privat <jean@pryen.org>
private import tables
redef class Token
private import tables
redef class Token
- var _text: nullable String
+ private var cached_text: nullable String
if res != null then return res
res = location.text
if res != null then return res
res = location.text
return res
end
redef fun text=(text)
do
return res
end
redef fun text=(text)
do
end
fun parser_index: Int is abstract
end
fun parser_index: Int is abstract
init init_tk(loc: Location)
do
init init_tk(loc: Location)
do
class Lexer
super TablesCapable
# Last peeked token
class Lexer
super TablesCapable
# Last peeked token
- var _token: nullable Token
+ var token: nullable Token
+ private var state: Int = 0
# The source file
var file: SourceFile
# Current character in the stream
# The source file
var file: SourceFile
# 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
super ANode
# All the annotations attached directly to the node
super ANode
# All the annotations attached directly to the node
- var _n_annotations: nullable AAnnotations = null
- fun n_annotations: nullable AAnnotations do return _n_annotations
- fun n_annotations=(n_annotations: nullable AAnnotations) do _n_annotations = n_annotations
+ var n_annotations: nullable AAnnotations = null is writable
redef fun replace_with(n: ANode)
do
redef fun replace_with(n: ANode)
do
end
# The current visited node
end
# The current visited node
- var _current_node: nullable ANode = null
- fun current_node: nullable ANode do return _current_node
- fun current_node=(current_node: nullable ANode) do _current_node = current_node
+ var current_node: nullable ANode = null is writable
end
# Token of end of line (basically `\n`)
end
# Token of end of line (basically `\n`)
# State of the parser automata as stored in the parser stack.
private class State
# The internal state number
# State of the parser automata as stored in the parser stack.
private class State
# The internal state number
# The node stored with the state in the stack
# The node stored with the state in the stack
- var _nodes: nullable Object
+ var nodes: nullable Object
init(state: Int, nodes: nullable Object)
do
init(state: Int, nodes: nullable Object)
do
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 is abstract
end
redef class Prod
# Location on the first token after the start of a production
# So outside the production for epilon production
private fun build_reduce_table is abstract
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
+ var first_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]
# 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: ANode)
do
redef fun visit(n: 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