Class: Malline::Parser
- Inherits:
-
Racc::Parser
- Object
- Racc::Parser
- Malline::Parser
- Defined in:
- lib/malline/parser.rb
Constant Summary collapse
- Racc_arg =
[ racc_action_table, racc_action_check, racc_action_default, racc_action_pointer, racc_goto_table, racc_goto_check, racc_goto_default, racc_goto_pointer, racc_nt_base, racc_reduce_table, racc_token_table, racc_shift_n, racc_reduce_n, racc_use_result_var ]
- Racc_token_to_s_table =
[ "$end", "error", "START_CODE", "END_CODE", "DATA", "CMD", "$start", "values", "value", "code_block", "data" ]
- Racc_debug_parser =
false
Instance Method Summary collapse
-
#_reduce_6(val, _values, result) ⇒ Object
reduce 5 omitted.
- #_reduce_7(val, _values, result) ⇒ Object
- #_reduce_8(val, _values, result) ⇒ Object
- #_reduce_none(val, _values, result) ⇒ Object
-
#initialize(lexer, handler = Handler.new) ⇒ Parser
constructor
A new instance of Parser.
- #next_token ⇒ Object
- #parse ⇒ Object
Constructor Details
#initialize(lexer, handler = Handler.new) ⇒ Parser
Returns a new instance of Parser.
14 15 16 17 18 |
# File 'lib/malline/parser.rb', line 14 def initialize lexer, handler=Handler.new @lexer = lexer @handler = handler super() end |
Instance Method Details
#_reduce_6(val, _values, result) ⇒ Object
reduce 5 omitted
132 133 134 135 |
# File 'lib/malline/parser.rb', line 132 def _reduce_6(val, _values, result) @handler.code(val[2], val[1].to_sym) result end |
#_reduce_7(val, _values, result) ⇒ Object
137 138 139 140 |
# File 'lib/malline/parser.rb', line 137 def _reduce_7(val, _values, result) @handler.code val[1] result end |
#_reduce_8(val, _values, result) ⇒ Object
142 143 144 145 |
# File 'lib/malline/parser.rb', line 142 def _reduce_8(val, _values, result) @handler.data val.first result end |
#_reduce_none(val, _values, result) ⇒ Object
147 148 149 |
# File 'lib/malline/parser.rb', line 147 def _reduce_none(val, _values, result) val[0] end |
#next_token ⇒ Object
20 21 22 23 24 |
# File 'lib/malline/parser.rb', line 20 def next_token token, string, start_line, end_line = @lexer.next_token @handler.token_line = [start_line, end_line] [token, string] if token end |
#parse ⇒ Object
26 27 28 29 |
# File 'lib/malline/parser.rb', line 26 def parse do_parse @handler end |