Class: Pegex::Grammar
- Inherits:
-
Object
- Object
- Pegex::Grammar
- Defined in:
- lib/pegex/grammar.rb
Defined Under Namespace
Classes: Atoms
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
-
#tree ⇒ Object
Returns the value of attribute tree.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Grammar
constructor
A new instance of Grammar.
- #make_tree ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Grammar
Returns a new instance of Grammar.
6 7 8 9 |
# File 'lib/pegex/grammar.rb', line 6 def initialize yield self if block_given? @tree ||= make_tree end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/pegex/grammar.rb', line 3 def text @text end |
#tree ⇒ Object
Returns the value of attribute tree.
4 5 6 |
# File 'lib/pegex/grammar.rb', line 4 def tree @tree end |
Instance Method Details
#make_tree ⇒ Object
17 18 19 20 |
# File 'lib/pegex/grammar.rb', line 17 def make_tree require 'pegex/compiler' return @tree = Pegex::Compiler.new.compile(@text).tree end |