Class: Ibex::TableSimulation::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/table_simulation/step.rb

Overview

One immutable parser-table action.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sequence:, state:, token_id:, token:, action:, action_source:, production_id:, lhs:, rhs_length:, target_state:, stack_depth_before:, stack_depth_after:) ⇒ Step

Returns a new instance of Step.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ibex/table_simulation/step.rb', line 24

def initialize(sequence:, state:, token_id:, token:, action:, action_source:, production_id:, lhs:, rhs_length:,
               target_state:, stack_depth_before:, stack_depth_after:)
  @sequence = sequence
  @state = state
  @token_id = token_id
  @token = token.dup.freeze
  @action = action.dup.freeze
  @action_source = action_source.dup.freeze
  @production_id = production_id
  @lhs = lhs&.dup&.freeze
  @rhs_length = rhs_length
  @target_state = target_state
  @stack_depth_before = stack_depth_before
  @stack_depth_after = stack_depth_after
  freeze
end

Instance Attribute Details

#actionObject (readonly)

: String



12
13
14
# File 'lib/ibex/table_simulation/step.rb', line 12

def action
  @action
end

#action_sourceObject (readonly)

: String



13
14
15
# File 'lib/ibex/table_simulation/step.rb', line 13

def action_source
  @action_source
end

#lhsObject (readonly)

: String?



15
16
17
# File 'lib/ibex/table_simulation/step.rb', line 15

def lhs
  @lhs
end

#production_idObject (readonly)

: Integer?



14
15
16
# File 'lib/ibex/table_simulation/step.rb', line 14

def production_id
  @production_id
end

#rhs_lengthObject (readonly)

: Integer?



16
17
18
# File 'lib/ibex/table_simulation/step.rb', line 16

def rhs_length
  @rhs_length
end

#sequenceObject (readonly)

: Integer



8
9
10
# File 'lib/ibex/table_simulation/step.rb', line 8

def sequence
  @sequence
end

#stack_depth_afterObject (readonly)

: Integer



19
20
21
# File 'lib/ibex/table_simulation/step.rb', line 19

def stack_depth_after
  @stack_depth_after
end

#stack_depth_beforeObject (readonly)

: Integer



18
19
20
# File 'lib/ibex/table_simulation/step.rb', line 18

def stack_depth_before
  @stack_depth_before
end

#stateObject (readonly)

: Integer



9
10
11
# File 'lib/ibex/table_simulation/step.rb', line 9

def state
  @state
end

#target_stateObject (readonly)

: Integer?



17
18
19
# File 'lib/ibex/table_simulation/step.rb', line 17

def target_state
  @target_state
end

#tokenObject (readonly)

: String



11
12
13
# File 'lib/ibex/table_simulation/step.rb', line 11

def token
  @token
end

#token_idObject (readonly)

: Integer



10
11
12
# File 'lib/ibex/table_simulation/step.rb', line 10

def token_id
  @token_id
end

Instance Method Details

#to_hObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ibex/table_simulation/step.rb', line 42

def to_h
  {
    "sequence" => @sequence,
    "state" => @state,
    "token_id" => @token_id,
    "token" => @token,
    "action" => @action,
    "action_source" => @action_source,
    "production_id" => @production_id,
    "lhs" => @lhs,
    "rhs_length" => @rhs_length,
    "target_state" => @target_state,
    "stack_depth_before" => @stack_depth_before,
    "stack_depth_after" => @stack_depth_after
  }.freeze
end