Class: Ibex::IR::AutomatonState
- Inherits:
-
Object
- Object
- Ibex::IR::AutomatonState
- Defined in:
- lib/ibex/ir/automaton_ir.rb
Overview
A deterministic LALR automaton state.
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
: Hash[Integer, parser_action].
-
#conflicts ⇒ Object
readonly
: Array.
-
#default_action ⇒ Object
readonly
: parser_action?.
-
#gotos ⇒ Object
readonly
: Hash[Integer, Integer].
-
#id ⇒ Object
readonly
: Integer.
-
#items ⇒ Object
readonly
: Array.
-
#transitions ⇒ Object
readonly
: Hash[Integer, Integer].
Instance Method Summary collapse
-
#initialize(id:, items:, transitions:, actions:, gotos:, default_action: nil, conflicts: []) ⇒ AutomatonState
constructor
A new instance of AutomatonState.
- #to_h(grammar) ⇒ Object
Constructor Details
#initialize(id:, items:, transitions:, actions:, gotos:, default_action: nil, conflicts: []) ⇒ AutomatonState
Returns a new instance of AutomatonState.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ibex/ir/automaton_ir.rb', line 42 def initialize(id:, items:, transitions:, actions:, gotos:, default_action: nil, conflicts: []) @id = id @items = items.freeze @transitions = IR.deep_freeze(transitions) @actions = IR.deep_freeze(actions) @gotos = IR.deep_freeze(gotos) @default_action = IR.deep_freeze(default_action) @conflicts = IR.deep_freeze(conflicts) freeze end |
Instance Attribute Details
#actions ⇒ Object (readonly)
: Hash[Integer, parser_action]
34 35 36 |
# File 'lib/ibex/ir/automaton_ir.rb', line 34 def actions @actions end |
#conflicts ⇒ Object (readonly)
: Array
37 38 39 |
# File 'lib/ibex/ir/automaton_ir.rb', line 37 def conflicts @conflicts end |
#default_action ⇒ Object (readonly)
: parser_action?
36 37 38 |
# File 'lib/ibex/ir/automaton_ir.rb', line 36 def default_action @default_action end |
#gotos ⇒ Object (readonly)
: Hash[Integer, Integer]
35 36 37 |
# File 'lib/ibex/ir/automaton_ir.rb', line 35 def gotos @gotos end |
#id ⇒ Object (readonly)
: Integer
31 32 33 |
# File 'lib/ibex/ir/automaton_ir.rb', line 31 def id @id end |
#items ⇒ Object (readonly)
: Array
32 33 34 |
# File 'lib/ibex/ir/automaton_ir.rb', line 32 def items @items end |
#transitions ⇒ Object (readonly)
: Hash[Integer, Integer]
33 34 35 |
# File 'lib/ibex/ir/automaton_ir.rb', line 33 def transitions @transitions end |
Instance Method Details
#to_h(grammar) ⇒ Object
54 55 56 57 58 |
# File 'lib/ibex/ir/automaton_ir.rb', line 54 def to_h(grammar) { id: @id, items: @items.map { |item| item.to_h(grammar) }, transitions: named_keys(@transitions, grammar), actions: named_keys(@actions, grammar), gotos: named_keys(@gotos, grammar), default_action: @default_action, conflicts: @conflicts } end |