Class: Antelope::Ace::Grammar::Production
- Inherits:
-
Struct
- Object
- Struct
- Antelope::Ace::Grammar::Production
- Defined in:
- lib/antelope/ace/grammar/production.rb
Overview
Defines a production.
Instance Attribute Summary collapse
-
#block ⇒ String
The block of code to be executed when the production's right hand side is reduced.
-
#id ⇒ Numeric
The ID of the production.
-
#items ⇒ Array<Token>
The body (or right-hand side) of the production.
-
#label ⇒ Symbol
The label (or left-hand side) of the production.
-
#prec ⇒ Ace::Precedence
The precedence declaration for the production.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates a new production from a hash.
Instance Attribute Details
#block ⇒ String
The block of code to be executed when the production's right hand side is reduced.
6 7 8 |
# File 'lib/antelope/ace/grammar/production.rb', line 6 def block @block end |
#id ⇒ Numeric
The ID of the production. The starting production always has an ID of 0.
6 7 8 |
# File 'lib/antelope/ace/grammar/production.rb', line 6 def id @id end |
#items ⇒ Array<Token>
The body (or right-hand side) of the production. This can be array of terminals and nonterminals.
6 7 8 |
# File 'lib/antelope/ace/grammar/production.rb', line 6 def items @items end |
#label ⇒ Symbol
The label (or left-hand side) of the production. This should be a nonterminal.
6 7 8 |
# File 'lib/antelope/ace/grammar/production.rb', line 6 def label @label end |
#prec ⇒ Ace::Precedence
The precedence declaration for the production.
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.
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 |