Class: LL::Bootstrap::Parser

Inherits:
Racc::Parser
  • Object
show all
Defined in:
lib/ll/bootstrap/parser.rb

Constant Summary

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",
"T_RUBY",
"T_NAME",
"T_TERMINALS",
"T_INNER",
"T_HEADER",
"T_IDENT",
"T_EQUALS",
"T_COLON",
"T_PIPE",
"T_EPSILON",
"T_SEMICOLON",
"$start",
"grammar",
"elements",
"element",
"directive",
"rule",
"name",
"terminals",
"inner",
"header",
"ident",
"name_ns",
"idents",
"ruby",
"idents_or_epsilon",
"epsilon",
"branch",
"branches" ]
Racc_debug_parser =
false

Instance Method Summary (collapse)

Constructor Details

- (Parser) initialize(*args)

Returns a new instance of Parser

See Also:

  • LL::Bootstrap::Parser.[LL[LL::Lexer[LL::Lexer#initialize]


15
16
17
# File 'lib/ll/bootstrap/parser.rb', line 15

def initialize(*args)
  @lexer = Lexer.new(*args)
end

Instance Method Details

- (Object) _reduce_1(val, _values)

reduce 0 omitted



208
209
210
# File 'lib/ll/bootstrap/parser.rb', line 208

def _reduce_1(val, _values)
 s(:grammar, val[0]) 
end

- (Object) _reduce_11(val, _values)

reduce 10 omitted



236
237
238
239
# File 'lib/ll/bootstrap/parser.rb', line 236

def _reduce_11(val, _values)
        s(:name, [val[1]], :source_line => val[0].source_line)
      
end

- (Object) _reduce_12(val, _values)



241
242
243
244
# File 'lib/ll/bootstrap/parser.rb', line 241

def _reduce_12(val, _values)
        s(:name, [val[1], *val[2]], :source_line => val[0].source_line)
      
end

- (Object) _reduce_13(val, _values)



246
247
248
# File 'lib/ll/bootstrap/parser.rb', line 246

def _reduce_13(val, _values)
 [val[2]] 
end

- (Object) _reduce_14(val, _values)



250
251
252
# File 'lib/ll/bootstrap/parser.rb', line 250

def _reduce_14(val, _values)
 [val[2]] + val[3] 
end

- (Object) _reduce_15(val, _values)



254
255
256
257
# File 'lib/ll/bootstrap/parser.rb', line 254

def _reduce_15(val, _values)
        s(:terminals, val[1], :source_line => val[0].source_line)
      
end

- (Object) _reduce_16(val, _values)



259
260
261
# File 'lib/ll/bootstrap/parser.rb', line 259

def _reduce_16(val, _values)
 s(:inner, [val[1]], :source_line => val[0].source_line) 
end

- (Object) _reduce_17(val, _values)



263
264
265
# File 'lib/ll/bootstrap/parser.rb', line 263

def _reduce_17(val, _values)
 s(:header, [val[1]], :source_line => val[0].source_line) 
end

- (Object) _reduce_18(val, _values)



267
268
269
# File 'lib/ll/bootstrap/parser.rb', line 267

def _reduce_18(val, _values)
 val 
end

- (Object) _reduce_19(val, _values)



271
272
273
# File 'lib/ll/bootstrap/parser.rb', line 271

def _reduce_19(val, _values)
 val[0] << val[1] 
end

- (Object) _reduce_2(val, _values)



212
213
214
# File 'lib/ll/bootstrap/parser.rb', line 212

def _reduce_2(val, _values)
 s(:grammar) 
end

- (Object) _reduce_20(val, _values)



275
276
277
# File 'lib/ll/bootstrap/parser.rb', line 275

def _reduce_20(val, _values)
 s(:ident, [val[0].value], :source_line => val[0].source_line) 
end

- (Object) _reduce_21(val, _values)



279
280
281
282
# File 'lib/ll/bootstrap/parser.rb', line 279

def _reduce_21(val, _values)
        s(:steps, val[0], :source_line => val[0][0].source_line)
      
end

- (Object) _reduce_22(val, _values)



284
285
286
287
# File 'lib/ll/bootstrap/parser.rb', line 284

def _reduce_22(val, _values)
        s(:steps, [val[0]], :source_line => val[0].source_line)
      
end

- (Object) _reduce_23(val, _values)



289
290
291
# File 'lib/ll/bootstrap/parser.rb', line 289

def _reduce_23(val, _values)
 s(:epsilon, [], :source_line => val[0].source_line) 
end

- (Object) _reduce_24(val, _values)



293
294
295
296
# File 'lib/ll/bootstrap/parser.rb', line 293

def _reduce_24(val, _values)
        s(:branch, [val[0]], :source_line => val[0].source_line)
      
end

- (Object) _reduce_25(val, _values)



298
299
300
301
# File 'lib/ll/bootstrap/parser.rb', line 298

def _reduce_25(val, _values)
        s(:branch, [val[0], val[1]], :source_line => val[0].source_line)
      
end

- (Object) _reduce_26(val, _values)



303
304
305
# File 'lib/ll/bootstrap/parser.rb', line 303

def _reduce_26(val, _values)
 val 
end

- (Object) _reduce_27(val, _values)



307
308
309
# File 'lib/ll/bootstrap/parser.rb', line 307

def _reduce_27(val, _values)
 [val[0]] + val[2] 
end

- (Object) _reduce_28(val, _values)



311
312
313
314
# File 'lib/ll/bootstrap/parser.rb', line 311

def _reduce_28(val, _values)
        s(:rule, [val[0], *val[2]], :source_line => val[0].source_line)
      
end

- (Object) _reduce_29(val, _values)



316
317
318
# File 'lib/ll/bootstrap/parser.rb', line 316

def _reduce_29(val, _values)
 s(:ruby, [val[0].value], :source_line => val[0].source_line) 
end

- (Object) _reduce_3(val, _values)



216
217
218
# File 'lib/ll/bootstrap/parser.rb', line 216

def _reduce_3(val, _values)
 val[0] << val[1] 
end

- (Object) _reduce_4(val, _values)



220
221
222
# File 'lib/ll/bootstrap/parser.rb', line 220

def _reduce_4(val, _values)
 val 
end

- (Object) _reduce_none(val, _values)



320
321
322
# File 'lib/ll/bootstrap/parser.rb', line 320

def _reduce_none(val, _values)
  val[0]
end

- (LL::AST::Node) parse

Parses the input and returns the corresponding AST.

Returns:



45
46
47
# File 'lib/ll/bootstrap/parser.rb', line 45

def parse
  return yyparse(self, :yield_next_token)
end

- (LL::AST::Node) s(*args)

Returns:

See Also:

  • LL::Bootstrap::Parser.[LL[LL::AST[LL::AST::Node[LL::AST::Node#initialize]


36
37
38
# File 'lib/ll/bootstrap/parser.rb', line 36

def s(*args)
  return AST::Node.new(*args)
end

- (Object) yield_next_token {|| ... }

Yields the next token from the lexer.

Yield Parameters:

  • (Array)


24
25
26
27
28
29
30
# File 'lib/ll/bootstrap/parser.rb', line 24

def yield_next_token
  @lexer.advance do |token|
    yield [token.type, token]
  end

  yield [false, false]
end