Class: Ibex::IR::Production
- Inherits:
-
Object
- Object
- Ibex::IR::Production
- Defined in:
- lib/ibex/ir/grammar_ir.rb
Overview
A normalized BNF production using symbol ids.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
: Action?.
-
#documentation ⇒ Object
readonly
: String?.
-
#expansion ⇒ Object
readonly
: production_expansion?.
-
#id ⇒ Object
readonly
: Integer.
-
#lhs ⇒ Object
readonly
: Integer.
-
#node ⇒ Object
readonly
: node_annotation?.
-
#origin ⇒ Object
readonly
: Hash[Symbol, Object?].
-
#precedence_override ⇒ Object
readonly
: Integer?.
-
#rhs ⇒ Object
readonly
: Array.
Instance Method Summary collapse
-
#initialize(id:, lhs:, rhs:, action:, precedence_override:, origin:, documentation: nil, expansion: nil, node: nil) ⇒ Production
constructor
A new instance of Production.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, lhs:, rhs:, action:, precedence_override:, origin:, documentation: nil, expansion: nil, node: nil) ⇒ Production
Returns a new instance of Production.
117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ibex/ir/grammar_ir.rb', line 117 def initialize(id:, lhs:, rhs:, action:, precedence_override:, origin:, documentation: nil, expansion: nil, node: nil) @id = id @lhs = lhs @rhs = IR.deep_freeze(rhs) @action = action @precedence_override = precedence_override @origin = IR.deep_freeze(origin) @documentation = documentation&.dup&.freeze @expansion = IR.deep_freeze(expansion) @node = IR.deep_freeze(node) freeze end |
Instance Attribute Details
#action ⇒ Object (readonly)
: Action?
107 108 109 |
# File 'lib/ibex/ir/grammar_ir.rb', line 107 def action @action end |
#documentation ⇒ Object (readonly)
: String?
110 111 112 |
# File 'lib/ibex/ir/grammar_ir.rb', line 110 def documentation @documentation end |
#expansion ⇒ Object (readonly)
: production_expansion?
111 112 113 |
# File 'lib/ibex/ir/grammar_ir.rb', line 111 def expansion @expansion end |
#id ⇒ Object (readonly)
: Integer
104 105 106 |
# File 'lib/ibex/ir/grammar_ir.rb', line 104 def id @id end |
#lhs ⇒ Object (readonly)
: Integer
105 106 107 |
# File 'lib/ibex/ir/grammar_ir.rb', line 105 def lhs @lhs end |
#node ⇒ Object (readonly)
: node_annotation?
112 113 114 |
# File 'lib/ibex/ir/grammar_ir.rb', line 112 def node @node end |
#origin ⇒ Object (readonly)
: Hash[Symbol, Object?]
109 110 111 |
# File 'lib/ibex/ir/grammar_ir.rb', line 109 def origin @origin end |
#precedence_override ⇒ Object (readonly)
: Integer?
108 109 110 |
# File 'lib/ibex/ir/grammar_ir.rb', line 108 def precedence_override @precedence_override end |
#rhs ⇒ Object (readonly)
: Array
106 107 108 |
# File 'lib/ibex/ir/grammar_ir.rb', line 106 def rhs @rhs end |
Instance Method Details
#to_h ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/ibex/ir/grammar_ir.rb', line 132 def to_h value = { id: @id, lhs: @lhs, rhs: @rhs, action: @action&.to_h, prec_override: @precedence_override, origin: @origin } #: Hash[Symbol, Object?] value[:doc] = @documentation value[:expansion] = @expansion value[:node] = @node if @node value end |