| Class | OOParser::Grammar |
| In: |
lib/ooparser/grammar.rb
(CVS)
|
| Parent: | Object |
| default_rule | [RW] | The default rule to enter a parse with |
| rules | [R] | Rules defined by the grammar |
Create a new OOParser::Grammar whose rules are defined in the given block.
# File lib/ooparser/grammar.rb, line 43 def initialize( &block ) @rules = {} @default_rule = nil self.instance_eval( &block ) if block end
Add a rule with the given name, production, and action to the parser’s grammar, creating a new Rule object if necessary.
# File lib/ooparser/grammar.rb, line 63 def def_rule( name, production, &action ) @rules[ name ] ||= OOParser::Rule::new( name ) @rules[ name ].add_production( production, &action ) @default_rule ||= name end