Class: Racc::GrammarFileParser

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

Overview

reopen

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debug_flags = DebugFlags.new) ⇒ GrammarFileParser

Returns a new instance of GrammarFileParser.



172
173
174
# File 'lib/racc/grammarfileparser.rb', line 172

def initialize(debug_flags = DebugFlags.new)
  @yydebug = debug_flags.parse
end

Class Method Details

.parse(src, filename = '-', lineno = 1) ⇒ Object



168
169
170
# File 'lib/racc/grammarfileparser.rb', line 168

def GrammarFileParser.parse(src, filename = '-', lineno = 1)
  new().parse(src, filename, lineno)
end

.parse_file(filename) ⇒ Object



164
165
166
# File 'lib/racc/grammarfileparser.rb', line 164

def GrammarFileParser.parse_file(filename)
  parse(File.read(filename), filename, 1)
end

Instance Method Details

#parse(src, filename = '-', lineno = 1) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/racc/grammarfileparser.rb', line 176

def parse(src, filename = '-', lineno = 1)
  @filename = filename
  @lineno = lineno
  @scanner = GrammarFileScanner.new(src, @filename)
  @scanner.debug = @yydebug
  @grammar = Grammar.new
  @result = Result.new(@grammar)
  @embedded_action_seq = 0
  yyparse @scanner, :yylex
  parse_user_code
  @result.grammar.init
  @result
end