Class: Pegex::Grammar

Inherits:
Object
  • Object
show all
Defined in:
lib/pegex/grammar.rb

Defined Under Namespace

Classes: Atoms

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Grammar

Returns a new instance of Grammar.

Yields:

  • (_self)

Yield Parameters:



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

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/pegex/grammar.rb', line 3

def text
  @text
end

#treeObject

Returns the value of attribute tree.



4
5
6
# File 'lib/pegex/grammar.rb', line 4

def tree
  @tree
end

Instance Method Details

#make_treeObject



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