Class: Ibex::IR::AutomatonItem
- Inherits:
-
Object
- Object
- Ibex::IR::AutomatonItem
- Defined in:
- lib/ibex/ir/automaton_ir.rb,
sig/ibex/ir/automaton_ir.rbs
Overview
A merged LALR item with its lookahead token ids.
Instance Attribute Summary collapse
- #dot ⇒ Integer readonly
- #lookaheads ⇒ Array[Integer] readonly
- #production ⇒ Integer readonly
Instance Method Summary collapse
-
#initialize(production:, dot:, lookaheads:) ⇒ AutomatonItem
constructor
A new instance of AutomatonItem.
- #to_h(grammar) ⇒ Hash[Symbol, untyped]
Constructor Details
#initialize(production:, dot:, lookaheads:) ⇒ AutomatonItem
Returns a new instance of AutomatonItem.
12 13 14 15 16 17 |
# File 'lib/ibex/ir/automaton_ir.rb', line 12 def initialize(production:, dot:, lookaheads:) @production = production @dot = dot @lookaheads = lookaheads.sort.freeze freeze end |
Instance Attribute Details
#dot ⇒ Integer (readonly)
8 9 10 |
# File 'lib/ibex/ir/automaton_ir.rb', line 8 def dot @dot end |
#lookaheads ⇒ Array[Integer] (readonly)
9 10 11 |
# File 'lib/ibex/ir/automaton_ir.rb', line 9 def lookaheads @lookaheads end |
#production ⇒ Integer (readonly)
7 8 9 |
# File 'lib/ibex/ir/automaton_ir.rb', line 7 def production @production end |
Instance Method Details
#to_h(grammar) ⇒ Hash[Symbol, untyped]
20 21 22 23 24 25 26 |
# File 'lib/ibex/ir/automaton_ir.rb', line 20 def to_h(grammar) { production: @production, dot: @dot, lookaheads: @lookaheads.map do |id| symbol = grammar.symbol_by_id(id) || raise(Ibex::Error, "missing grammar symbol id #{id}") symbol.name end } end |