Class: Ibex::TableSimulation::Step

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

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.

RBS:

  • (sequence: Integer, state: Integer, token_id: Integer, token: String, action: String, action_source: String, production_id: Integer?, lhs: String?, rhs_length: Integer?, target_state: Integer?, stack_depth_before: Integer, stack_depth_after: Integer) -> void

Parameters:

  • sequence: (Integer)
  • state: (Integer)
  • token_id: (Integer)
  • token: (String)
  • action: (String)
  • action_source: (String)
  • production_id: (Integer, nil)
  • lhs: (String, nil)
  • rhs_length: (Integer, nil)
  • target_state: (Integer, nil)
  • stack_depth_before: (Integer)
  • stack_depth_after: (Integer)


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

#actionString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def action
  @action
end

#action_sourceString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def action_source
  @action_source
end

#lhsString? (readonly)

Signature:

  • String?

Returns:

  • (String, nil)


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

def lhs
  @lhs
end

#production_idInteger? (readonly)

Signature:

  • Integer?

Returns:

  • (Integer, nil)


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

def production_id
  @production_id
end

#rhs_lengthInteger? (readonly)

Signature:

  • Integer?

Returns:

  • (Integer, nil)


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

def rhs_length
  @rhs_length
end

#sequenceInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def sequence
  @sequence
end

#stack_depth_afterInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def stack_depth_after
  @stack_depth_after
end

#stack_depth_beforeInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def stack_depth_before
  @stack_depth_before
end

#stateInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def state
  @state
end

#target_stateInteger? (readonly)

Signature:

  • Integer?

Returns:

  • (Integer, nil)


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

def target_state
  @target_state
end

#tokenString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def token
  @token
end

#token_idInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def token_id
  @token_id
end

Instance Method Details

#to_hHash[String, untyped]

RBS:

  • () -> Hash[String, untyped]

Returns:

  • (Hash[String, untyped])


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