Class: Stupidedi::Builder::InitialState

Inherits:
AbstractState show all
Defined in:
lib/stupidedi/builder/states/initial_state.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractState

#leaf?, lsequence, mkcomposite, mkelement, mkrepeated, mksegment, mksimple, #pretty_print, push, sequence, tsequence

Methods included from Inspect

#inspect

Constructor Details

#initialize(separators, segment_dict, instructions, zipper, children) ⇒ InitialState

Returns a new instance of InitialState.



24
25
26
27
# File 'lib/stupidedi/builder/states/initial_state.rb', line 24

def initialize(separators, segment_dict, instructions, zipper, children)
  @separators, @segment_dict, @instructions, @zipper, @children =
    separators, segment_dict, instructions, zipper, children
end

Instance Attribute Details

#childrenArray<AbstractState> (readonly)

Returns:



22
23
24
# File 'lib/stupidedi/builder/states/initial_state.rb', line 22

def children
  @children
end

#instructionsInstructionTable (readonly)

Returns:



16
17
18
# File 'lib/stupidedi/builder/states/initial_state.rb', line 16

def instructions
  @instructions
end

#segment_dictReader::SegmentDict (readonly)

Returns:



13
14
15
# File 'lib/stupidedi/builder/states/initial_state.rb', line 13

def segment_dict
  @segment_dict
end

#separatorsReader::Separators (readonly)

Returns:



10
11
12
# File 'lib/stupidedi/builder/states/initial_state.rb', line 10

def separators
  @separators
end

#zipperZipper::AbstractCursor (readonly)



19
20
21
# File 'lib/stupidedi/builder/states/initial_state.rb', line 19

def zipper
  @zipper
end

Class Method Details

.buildInitialState

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/stupidedi/builder/states/initial_state.rb', line 43

def build
  new(
    Reader::Separators.empty,
    Reader::SegmentDict.empty,

    InstructionTable.build(
      # We initially accept only a single segment. When reading the "ISA"
      # segment, we push a new InterchangeState.
      Instruction.new(:ISA, nil, 0, 0, TransmissionState).cons),

    # Create a new parse tree with a Transmission as the root, and descend
    # to the placeholder where the first child node will be placed.
    Zipper.build(Values::TransmissionVal.new),
    [])
end

.startZipper::AbstractCursor



60
61
62
# File 'lib/stupidedi/builder/states/initial_state.rb', line 60

def start
  Zipper.build(build)
end

Instance Method Details

#copy(changes = {}) ⇒ InitialState

Returns:



30
31
32
33
34
35
36
37
# File 'lib/stupidedi/builder/states/initial_state.rb', line 30

def copy(changes = {})
  InitialState.new \
    changes.fetch(:separators, @separators),
    changes.fetch(:segment_dict, @segment_dict),
    changes.fetch(:instructions, @instructions),
    changes.fetch(:zipper, @zipper),
    changes.fetch(:children, @children)
end