Class: Depager::CSTBuilderExtension::PreRuleList0::Parser
- Inherits:
-
LALR::Basis
- Object
- LALR::Parser
- LALR::Basis
- Depager::CSTBuilderExtension::PreRuleList0::Parser
- Includes:
- Utils::ExtensionSlaveMethods
- Defined in:
- lib/depager/plugins/cst.rb
Overview
:nodoc:all
Constant Summary collapse
- REDUCE_TABLE =
Reduce Table
[ [ -1, 1 ], [ 0, 2 ], [ 1, 0 ], [ 1, 2 ], [ 2, 0 ], [ 2, 2 ], ]
- TERM_TO_INT =
Term to Int
{ nil => 0, false => 1, :NODE => 2, :ACTION => 3, :VISITOR => 4, }
- INT_TO_TERM =
Int to Term
[ nil, false, :NODE, :ACTION, :VISITOR, ]
- ACTION_TABLE =
Action Table
[ [ nil, nil, 3, nil, nil, ], [ ACC, nil, nil, nil, nil, ], [ nil, nil, nil, nil, 5, ], [ nil, nil, nil, 6, nil, ], [ nil, nil, nil, nil, nil, ], [ nil, nil, nil, 7, nil, ], [ nil, nil, nil, nil, nil, ], [ nil, nil, nil, nil, nil, ], ]
- DEFRED_TABLE =
Default Reduce Table
[ -2, nil, -4, nil, -1, nil, -3, -5, ]
- DEFRED_AFTER_SHIFT_TABLE =
[ nil, nil, nil, nil, -1, nil, -3, -5, ]
- NONTERM_TO_INT =
Nonterm to Int
{ :start => 0, :opt_node => 1, :opt_visitor => 2, }
- INT_TO_NONTERM =
Int to Nonterm
[ :start, :opt_node, :opt_visitor, ]
- GOTO_TABLE =
Goto Table
[ [ 1, 2, nil, ], [ nil, nil, nil, ], [ nil, nil, 4, ], [ nil, nil, nil, ], [ nil, nil, nil, ], [ nil, nil, nil, ], [ nil, nil, nil, ], [ nil, nil, nil, ], ]
Constants inherited from LALR::Parser
Instance Attribute Summary
Attributes included from Utils::ExtensionSlaveMethods
Attributes inherited from LALR::Basis
#action_value, #basis, #file, #line, #lookahead, #parser_size, #stack
Instance Method Summary collapse
- #action_table ⇒ Object
- #banner ⇒ Object
- #defred_after_shift_table ⇒ Object
- #defred_table ⇒ Object
- #do_parse? ⇒ Boolean
- #goto_table ⇒ Object
-
#initialize(g_parser, master) ⇒ Parser
constructor
A new instance of Parser.
- #int_to_nonterm ⇒ Object
- #int_to_term ⇒ Object
- #lex {|nil, nil| ... } ⇒ Object
- #nonterm_to_int ⇒ Object
- #reduce_table ⇒ Object
- #term_to_int ⇒ Object
Methods included from Utils::ExtensionSlaveMethods
#abort_driver, #do_default, #do_parse
Methods included from Utils::CodeGeneratorMethods
#expand_inline_code, #generate_action_decorator_code, #generate_decorator_code, #parse_block
Methods included from Utils::CommonMethods
#error_exit, #error_message, #expanded_code_delimiter, #file, #full_target_name, #input_path, #inspect, #target_name, #target_namespace, #warning
Methods inherited from LALR::Basis
#abort_driver, #accept, #do_abort_driver, #error, #next_decorator_index, #reduce, #shift
Methods inherited from LALR::Parser
#accept, #error, #parse, #reduce, #shift
Constructor Details
Instance Method Details
#action_table ⇒ Object
158 |
# File 'lib/depager/plugins/cst.rb', line 158 def action_table; ACTION_TABLE; end |
#banner ⇒ Object
233 234 235 |
# File 'lib/depager/plugins/cst.rb', line 233 def "%CST{ ... } / Depager::CSTBuilderExtension" end |
#defred_after_shift_table ⇒ Object
183 |
# File 'lib/depager/plugins/cst.rb', line 183 def defred_after_shift_table; DEFRED_AFTER_SHIFT_TABLE; end |
#defred_table ⇒ Object
171 |
# File 'lib/depager/plugins/cst.rb', line 171 def defred_table; DEFRED_TABLE; end |
#do_parse? ⇒ Boolean
223 224 225 226 227 228 229 230 |
# File 'lib/depager/plugins/cst.rb', line 223 def do_parse? if @line.match(/^\s*%CST\{\s*\Z/) @line = $' true else false end end |
#goto_table ⇒ Object
212 |
# File 'lib/depager/plugins/cst.rb', line 212 def goto_table; GOTO_TABLE; end |
#int_to_nonterm ⇒ Object
199 |
# File 'lib/depager/plugins/cst.rb', line 199 def int_to_nonterm; INT_TO_NONTERM; end |
#int_to_term ⇒ Object
145 |
# File 'lib/depager/plugins/cst.rb', line 145 def int_to_term; INT_TO_TERM; end |
#lex {|nil, nil| ... } ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/depager/plugins/cst.rb', line 237 def lex begin until @line.empty? case @line when /\A\s+/, /\A#.*/ @line = $' when /\A%\}\s*\Z/ @line = $' yield nil,nil when /\ANode/ @line = $' yield token(:NODE, $&) when /\AVisitor/ @line = $' yield token(:VISITOR, $&) when /\A\{/ # lineno = file.lineno; yield token(:ACTION, parse_block, lineno) else raise RuntimeError, "must not happen #{@line}" end end end while @original_line = @line = file.gets yield nil, nil end |
#nonterm_to_int ⇒ Object
191 |
# File 'lib/depager/plugins/cst.rb', line 191 def nonterm_to_int; NONTERM_TO_INT; end |
#reduce_table ⇒ Object
125 |
# File 'lib/depager/plugins/cst.rb', line 125 def reduce_table; REDUCE_TABLE; end |
#term_to_int ⇒ Object
135 |
# File 'lib/depager/plugins/cst.rb', line 135 def term_to_int; TERM_TO_INT; end |