Class: Srgs::Grammar

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root = '') ⇒ Grammar

Returns a new instance of Grammar.



6
7
8
9
10
11
12
# File 'lib/srgs/elements/grammar.rb', line 6

def initialize(root = '')
  @root = root
  @lexicon = nil
  @metas = Array.new
  @rules = Array.new
  @current_level = nil
end

Instance Attribute Details

#current_levelObject

Returns the value of attribute current_level.



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

def current_level
  @current_level
end

#lexiconObject

Returns the value of attribute lexicon.



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

def lexicon
  @lexicon
end

#metasObject

Returns the value of attribute metas.



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

def metas
  @metas
end

#rootObject

Returns the value of attribute root.



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

def root
  @root
end

#rulesObject

Returns the value of attribute rules.



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

def rules
  @rules
end

Instance Method Details

#<<(element) ⇒ Object



14
15
16
17
18
19
# File 'lib/srgs/elements/grammar.rb', line 14

def <<(element)
  @rules << element if element.is_a? Rule
  @lexicon = element if element.is_a? Lexicon
  @metas << element if element.is_a? Meta
  self
end