Module: Antelope::Ace::Grammar::Terminals

Included in:
Antelope::Ace::Grammar
Defined in:
lib/antelope/ace/grammar/terminals.rb

Overview

Manages a list of the terminals in the grammar.

Instance Method Summary collapse

Instance Method Details

#nonterminalsArray<Symbol>

A list of all nonterminals in the grammar.

Returns:

  • (Array<Symbol>)

See Also:



27
28
29
# File 'lib/antelope/ace/grammar/terminals.rb', line 27

def nonterminals
  @_nonterminals ||= productions.keys
end

#symbolsArray<Token::Terminal, Symbol>

A list of all symbols in the grammar; includes both terminals and nonterminals.

Returns:

See Also:



37
38
39
# File 'lib/antelope/ace/grammar/terminals.rb', line 37

def symbols
  @_symbols ||= terminals + nonterminals
end

#terminalsArray<Token::Terminal>

A list of all terminals in the grammar. Checks the compiler options for terminals, and then returns an array of terminals. Caches the result.

Returns:



15
16
17
18
19
20
21
# File 'lib/antelope/ace/grammar/terminals.rb', line 15

def terminals
  @_terminals ||= begin
    @compiler.options.fetch(:terminals, []).map do |v|
      Token::Terminal.new(*v)
    end
  end
end