Class: Antelope::Ace::Grammar::Production

Inherits:
Struct
  • Object
show all
Defined in:
lib/antelope/ace/grammar/production.rb

Overview

Defines a production.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#blockString

The block of code to be executed when the production's right hand side is reduced.

Returns:

  • (String)


6
7
8
# File 'lib/antelope/ace/grammar/production.rb', line 6

def block
  @block
end

#idNumeric

The ID of the production. The starting production always has an ID of 0.

Returns:

  • (Numeric)


6
7
8
# File 'lib/antelope/ace/grammar/production.rb', line 6

def id
  @id
end

#itemsArray<Token>

The body (or right-hand side) of the production. This can be array of terminals and nonterminals.

Returns:



6
7
8
# File 'lib/antelope/ace/grammar/production.rb', line 6

def items
  @items
end

#labelSymbol

The label (or left-hand side) of the production. This should be a nonterminal.

Returns:

  • (Symbol)


6
7
8
# File 'lib/antelope/ace/grammar/production.rb', line 6

def label
  @label
end

#precAce::Precedence

The precedence declaration for the production.

Returns:



6
7
8
# File 'lib/antelope/ace/grammar/production.rb', line 6

def prec
  @prec
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates a new production from a hash. The hash's keys correspond to the attributes on this class.

Parameters:

  • hash (Hash<(Symbol, Object)>)


36
37
38
39
40
41
42
# File 'lib/antelope/ace/grammar/production.rb', line 36

def self.from_hash(hash)
  new(hash[:label] || hash["label"],
      hash[:items] || hash["items"],
      hash[:block] || hash["block"],
      hash[:prec]  || hash["prec"],
      hash[:id]    || hash["id"])
end