Class: Antelope::Ace::Grammar

Inherits:
Object
  • Object
show all
Includes:
Generation, Loading, Precedences, Productions, Terminals
Defined in:
lib/antelope/ace/grammar.rb,
lib/antelope/ace/grammar/loading.rb,
lib/antelope/ace/grammar/terminals.rb,
lib/antelope/ace/grammar/generation.rb,
lib/antelope/ace/grammar/precedences.rb,
lib/antelope/ace/grammar/productions.rb

Overview

Defines a grammar from an Ace file. This handles setting up productions, loading from files, terminals, precedence, and generation.

Defined Under Namespace

Modules: Generation, Loading, Precedences, Productions, Terminals

Constant Summary collapse

DEFAULT_MODIFIERS =

The default modifiers for generation. It's not really recommended to (heh) modify this; however, adding your own modifier is always acceptable.

[
  [:recognizer,  Generation::Recognizer ],
  [:constructor, Generation::Constructor],
  [:tableizer,   Generation::Tableizer  ]
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Generation

#find_generators, #generate

Methods included from Loading

included

Methods included from Precedences

#generate_precedence, #precedence, #precedence_for

Methods included from Productions

#all_productions, #default_production, #find_token, #generate_production_for, #generate_productions, #productions

Methods included from Terminals

#nonterminals, #symbols, #terminals

Constructor Details

#initialize(name, output, compiler) ⇒ Grammar

Initialize.

Parameters:

  • name (String)
  • output (String)

    the output directory. Automagically turned into a Pathname.

  • compiler (Compiler)


53
54
55
56
57
# File 'lib/antelope/ace/grammar.rb', line 53

def initialize(name, output, compiler)
  @name     = name
  @output   = Pathname.new(output)
  @compiler = compiler
end

Instance Attribute Details

#compilerCompiler (readonly)

The compiler for the Ace file.

Returns:



45
46
47
# File 'lib/antelope/ace/grammar.rb', line 45

def compiler
  @compiler
end

#nameString

The name of the grammar. This is normally assumed from a file name.

Returns:

  • (String)


34
35
36
# File 'lib/antelope/ace/grammar.rb', line 34

def name
  @name
end

#outputPathname

The output directory for the grammar. This is normally the same directory as the Ace file.

Returns:

  • (Pathname)


40
41
42
# File 'lib/antelope/ace/grammar.rb', line 40

def output
  @output
end

#statesSet<Generation::Recognizer::State>

Used by a generation class; this is all the generated states of the grammar.



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

def states
  @states
end