Class: Aurum::Grammar::SyntaxRules::Production

Inherits:
Struct
  • Object
show all
Defined in:
lib/aurum/grammar/syntax_rules.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



65
66
67
# File 'lib/aurum/grammar/syntax_rules.rb', line 65

def name
  @name
end

#nonterminalObject

Returns the value of attribute nonterminal

Returns:

  • (Object)

    the current value of nonterminal



64
65
66
# File 'lib/aurum/grammar/syntax_rules.rb', line 64

def nonterminal
  @nonterminal
end

#symbolsObject

Returns the value of attribute symbols

Returns:

  • (Object)

    the current value of symbols



64
65
66
# File 'lib/aurum/grammar/syntax_rules.rb', line 64

def symbols
  @symbols
end

Instance Method Details

#inspectObject



72
73
74
# File 'lib/aurum/grammar/syntax_rules.rb', line 72

def inspect
  "#{nonterminal.inspect} -> #{symbols.map {|symbol| symbol.inspect}.join(' ')}"
end

#precedenceObject



67
68
69
70
# File 'lib/aurum/grammar/syntax_rules.rb', line 67

def precedence
  terminals = symbols.find_all {|symbol| symbol.is_terminal && symbol.precedence}
  terminals.size == 1 ? terminals.first.precedence : Precedence::Highest
end