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, untyped].
-
#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(schema_version: SCHEMA_VERSION) ⇒ Object
Constructor Details
#initialize(id:, lhs:, rhs:, action:, precedence_override:, origin:, documentation: nil, expansion: nil, node: nil) ⇒ Production
Returns a new instance of Production.
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/ibex/ir/grammar_ir.rb', line 109 def initialize(id:, lhs:, rhs:, action:, precedence_override:, origin:, documentation: nil, expansion: nil, node: nil) @id = id @lhs = lhs @rhs = rhs.freeze @action = action @precedence_override = precedence_override @origin = IR.deep_freeze(origin) @documentation = documentation&.freeze @expansion = IR.deep_freeze(expansion) @node = IR.deep_freeze(node) freeze end |
Instance Attribute Details
#action ⇒ Object (readonly)
: Action?
99 100 101 |
# File 'lib/ibex/ir/grammar_ir.rb', line 99 def action @action end |
#documentation ⇒ Object (readonly)
: String?
102 103 104 |
# File 'lib/ibex/ir/grammar_ir.rb', line 102 def documentation @documentation end |
#expansion ⇒ Object (readonly)
: production_expansion?
103 104 105 |
# File 'lib/ibex/ir/grammar_ir.rb', line 103 def expansion @expansion end |
#id ⇒ Object (readonly)
: Integer
96 97 98 |
# File 'lib/ibex/ir/grammar_ir.rb', line 96 def id @id end |
#lhs ⇒ Object (readonly)
: Integer
97 98 99 |
# File 'lib/ibex/ir/grammar_ir.rb', line 97 def lhs @lhs end |
#node ⇒ Object (readonly)
: node_annotation?
104 105 106 |
# File 'lib/ibex/ir/grammar_ir.rb', line 104 def node @node end |
#origin ⇒ Object (readonly)
: Hash[Symbol, untyped]
101 102 103 |
# File 'lib/ibex/ir/grammar_ir.rb', line 101 def origin @origin end |
#precedence_override ⇒ Object (readonly)
: Integer?
100 101 102 |
# File 'lib/ibex/ir/grammar_ir.rb', line 100 def precedence_override @precedence_override end |
#rhs ⇒ Object (readonly)
: Array
98 99 100 |
# File 'lib/ibex/ir/grammar_ir.rb', line 98 def rhs @rhs end |
Instance Method Details
#to_h(schema_version: SCHEMA_VERSION) ⇒ Object
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/ibex/ir/grammar_ir.rb', line 124 def to_h(schema_version: SCHEMA_VERSION) value = { id: @id, lhs: @lhs, rhs: @rhs, action: @action&.to_h(schema_version: schema_version), prec_override: @precedence_override, origin: @origin } #: Hash[Symbol, untyped] if schema_version >= 2 value[:doc] = @documentation value[:expansion] = @expansion value[:node] = @node if @node end value end |