Class: Stupidedi::Parser::InitialState
- Inherits:
-
AbstractState
- Object
- AbstractState
- Stupidedi::Parser::InitialState
- Defined in:
- lib/stupidedi/parser/states/initial_state.rb
Instance Attribute Summary collapse
- #children ⇒ Array<AbstractState> readonly
- #instructions ⇒ InstructionTable readonly
- #segment_dict ⇒ Reader::SegmentDict readonly
- #separators ⇒ Reader::Separators readonly
- #zipper ⇒ Zipper::AbstractCursor readonly
Class Method Summary collapse
Instance Method Summary collapse
- #copy(changes = {}) ⇒ InitialState
-
#initialize(separators, segment_dict, instructions, zipper, children) ⇒ InitialState
constructor
A new instance of InitialState.
Methods inherited from AbstractState
#leaf?, lsequence, mkcomposite, mkelement, mkrepeated, mksegment, mksimple, #pretty_print, push, sequence, tsequence
Methods included from Inspect
Constructor Details
#initialize(separators, segment_dict, instructions, zipper, children) ⇒ InitialState
Returns a new instance of InitialState.
22 23 24 25 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 22 def initialize(separators, segment_dict, instructions, zipper, children) @separators, @segment_dict, @instructions, @zipper, @children = separators, segment_dict, instructions, zipper, children end |
Instance Attribute Details
#children ⇒ Array<AbstractState> (readonly)
20 21 22 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 20 def children @children end |
#instructions ⇒ InstructionTable (readonly)
14 15 16 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 14 def instructions @instructions end |
#segment_dict ⇒ Reader::SegmentDict (readonly)
11 12 13 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 11 def segment_dict @segment_dict end |
#separators ⇒ Reader::Separators (readonly)
8 9 10 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 8 def separators @separators end |
#zipper ⇒ Zipper::AbstractCursor (readonly)
17 18 19 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 17 def zipper @zipper end |
Class Method Details
.build(zipper) ⇒ InitialState
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 40 def build(zipper) 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 |
.start(zipper) ⇒ Zipper::AbstractCursor
57 58 59 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 57 def start(zipper) zipper.build(build(zipper)) end |
Instance Method Details
#copy(changes = {}) ⇒ InitialState
28 29 30 31 32 33 34 35 |
# File 'lib/stupidedi/parser/states/initial_state.rb', line 28 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 |