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.


297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/racc/grammarfileparser.rb', line 297

def initialize(str, filename = '-')
  @lines  = str.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


316
317
318
# File 'lib/racc/grammarfileparser.rb', line 316

def debug
  @debug
end

#epilogueObject (readonly)

Returns the value of attribute epilogue


310
311
312
# File 'lib/racc/grammarfileparser.rb', line 310

def epilogue
  @epilogue
end

Instance Method Details

#linenoObject


312
313
314
# File 'lib/racc/grammarfileparser.rb', line 312

def lineno
  @lineno + 1
end

#yylex(&block) ⇒ Object


318
319
320
321
322
323
324
325
326
327
# File 'lib/racc/grammarfileparser.rb', line 318

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