Class: Racc::GrammarFileScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/racc/grammarfileparser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, filename = '-') ⇒ GrammarFileScanner

Returns a new instance of GrammarFileScanner.



403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/racc/grammarfileparser.rb', line 403

def initialize(str, filename = '-')
  @lines  = str.b.split(/\n|\r\n|\r/)
  @filename = filename
  @lineno = -1
  @line_head   = true
  @in_rule_blk = false
  @in_conv_blk = false
  @in_block = nil
  @epilogue = ''
  @debug = false
  next_line
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



422
423
424
# File 'lib/racc/grammarfileparser.rb', line 422

def debug
  @debug
end

#epilogueObject (readonly)

Returns the value of attribute epilogue.



416
417
418
# File 'lib/racc/grammarfileparser.rb', line 416

def epilogue
  @epilogue
end

Instance Method Details

#linenoObject



418
419
420
# File 'lib/racc/grammarfileparser.rb', line 418

def lineno
  @lineno + 1
end

#yylex(&block) ⇒ Object



424
425
426
427
428
429
430
431
432
433
# File 'lib/racc/grammarfileparser.rb', line 424

def yylex(&block)
  unless @debug
    yylex0(&block)
  else
    yylex0 do |sym, tok|
      $stderr.printf "%7d %-10s %s\n", lineno(), sym.inspect, tok.inspect
      yield [sym, tok]
    end
  end
end