Class: Ibex::IR::AutomatonState

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/ir/automaton_ir.rb

Overview

A deterministic LALR automaton state.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#actionsObject (readonly)

: Hash[Integer, parser_action]



34
35
36
# File 'lib/ibex/ir/automaton_ir.rb', line 34

def actions
  @actions
end

#conflictsObject (readonly)

: Array



37
38
39
# File 'lib/ibex/ir/automaton_ir.rb', line 37

def conflicts
  @conflicts
end

#default_actionObject (readonly)

: parser_action?



36
37
38
# File 'lib/ibex/ir/automaton_ir.rb', line 36

def default_action
  @default_action
end

#gotosObject (readonly)

: Hash[Integer, Integer]



35
36
37
# File 'lib/ibex/ir/automaton_ir.rb', line 35

def gotos
  @gotos
end

#idObject (readonly)

: Integer



31
32
33
# File 'lib/ibex/ir/automaton_ir.rb', line 31

def id
  @id
end

#itemsObject (readonly)

: Array



32
33
34
# File 'lib/ibex/ir/automaton_ir.rb', line 32

def items
  @items
end

#transitionsObject (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