Class: Packrat::Grammar

Inherits:
Object
  • Object
show all
Extended by:
GrammarBuild
Defined in:
lib/packrat/grammar.rb

Instance Attribute Summary

Attributes included from GrammarBuild

#start

Class Method Summary collapse

Methods included from GrammarBuild

[], any, ast, ast_class, ast_class_name, each_prod, each_rule, eos, finalize!, hidden, internal_rule_name, lift, make_ast_class, maybe, mult, next_internal_rule_num, plus, postprocess_set_grammar_on_rules, prod, rep, rule, rules, sexpr, start_rule, start_symbol

Class Method Details

.interpreting_parser(klass = Packrat::InterpretingParser) ⇒ Object



197
198
199
200
# File 'lib/packrat/grammar.rb', line 197

def interpreting_parser(klass = Packrat::InterpretingParser)
  self.finalize!
  klass.new_subclass(self)
end

.new(&grammarBuilder) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
# File 'lib/packrat/grammar.rb', line 185

def new(&grammarBuilder)
  # We must name all the sub-classes so that its AST tree classes
  # are named.
  @num_grammars ||= 0
  const_set("Grammar" + (@num_grammars += 1).to_s, 
            klass = Class.new(self))
  # Add a module to hold the AST classes
  klass.const_set("ASTs", Module.new)
  klass.module_eval(&grammarBuilder)
  klass
end