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/production.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 Classes: Production

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
DEFAULT_GENERATORS =
{
  "ruby" => [Generator::Ruby]
}

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)


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

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:



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

def compiler
  @compiler
end

#nameString

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

Returns:

  • (String)


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

def name
  @name
end

#outputPathname

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

Returns:

  • (Pathname)


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

def output
  @output
end

#statesSet<Generation::Recognizer::State>

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



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

def states
  @states
end