Sha256: 0df79e06a54c92457e3ca21a7e57b209acaf514b4d630b1a8872e9e842d25709

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

module Antelope
  module Ace
    class Grammar

      # Manages a list of the terminals in the grammar.
      module Terminals

        # A list of all terminals in the grammar.  Checks the compiler
        # options for terminals, and then returns an array of
        # terminals.  Caches the result.
        #
        # @return [Array<Token::Terminal>]
        def terminals
          @_terminals ||= begin
            @compiler.options.fetch(:terminals, []).map do |v|
              Token::Terminal.new(*v)
            end
          end
        end

        # A list of all nonterminals in the grammar.
        #
        # @return [Array<Symbol>]
        # @see #productions
        def nonterminals
          @_nonterminals ||= productions.keys
        end

        # A list of all symbols in the grammar; includes both
        # terminals and nonterminals.
        #
        # @return [Array<Token::Terminal, Symbol>]
        # @see #terminals
        # @see #nonterminals
        def symbols
          @_symbols ||= terminals + nonterminals
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
antelope-0.1.8 lib/antelope/ace/grammar/terminals.rb
antelope-0.1.7 lib/antelope/ace/grammar/terminals.rb
antelope-0.1.6 lib/antelope/ace/grammar/terminals.rb
antelope-0.1.5 lib/antelope/ace/grammar/terminals.rb
antelope-0.1.4 lib/antelope/ace/grammar/terminals.rb
antelope-0.1.3 lib/antelope/ace/grammar/terminals.rb
antelope-0.1.2 lib/antelope/ace/grammar/terminals.rb