Class: Ibex::IR::Production
- Inherits:
-
Object
- Object
- Ibex::IR::Production
- Defined in:
- lib/ibex/ir/grammar_ir.rb,
sig/ibex/ir/grammar_ir.rbs
Overview
A normalized BNF production using symbol ids.
Instance Attribute Summary collapse
- #action ⇒ Action? readonly
- #documentation ⇒ String? readonly
- #expansion ⇒ production_expansion? readonly
- #id ⇒ Integer readonly
- #lhs ⇒ Integer readonly
- #node ⇒ node_annotation? readonly
- #origin ⇒ Hash[Symbol, untyped] readonly
- #precedence_override ⇒ Integer? readonly
- #rhs ⇒ Array[Integer] readonly
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) ⇒ Hash[Symbol, untyped]
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 ⇒ Action? (readonly)
99 100 101 |
# File 'lib/ibex/ir/grammar_ir.rb', line 99 def action @action end |
#documentation ⇒ String? (readonly)
102 103 104 |
# File 'lib/ibex/ir/grammar_ir.rb', line 102 def documentation @documentation end |
#expansion ⇒ production_expansion? (readonly)
103 104 105 |
# File 'lib/ibex/ir/grammar_ir.rb', line 103 def expansion @expansion end |
#id ⇒ Integer (readonly)
96 97 98 |
# File 'lib/ibex/ir/grammar_ir.rb', line 96 def id @id end |
#lhs ⇒ Integer (readonly)
97 98 99 |
# File 'lib/ibex/ir/grammar_ir.rb', line 97 def lhs @lhs end |
#node ⇒ node_annotation? (readonly)
104 105 106 |
# File 'lib/ibex/ir/grammar_ir.rb', line 104 def node @node end |
#origin ⇒ Hash[Symbol, untyped] (readonly)
101 102 103 |
# File 'lib/ibex/ir/grammar_ir.rb', line 101 def origin @origin end |
#precedence_override ⇒ Integer? (readonly)
100 101 102 |
# File 'lib/ibex/ir/grammar_ir.rb', line 100 def precedence_override @precedence_override end |
#rhs ⇒ Array[Integer] (readonly)
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) ⇒ Hash[Symbol, untyped]
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 |