Class: Stupidedi::Parser::StateMachine

Inherits:
Object
  • Object
show all
Includes:
Inspect, Generation, Navigation, Tokenization
Defined in:
lib/stupidedi/parser/state_machine.rb

Instance Attribute Summary collapse

Constructors collapse

Instance Method Summary collapse

Methods included from Tokenization

#blank, #composite, #default, #not_used, #repeated

Methods included from Generation

#execute, #insert, #read, #update_reader

Methods included from Navigation

#count, #count!, #deterministic?, #distance, #element, #elementn, #empty?, #find, #find!, #first, #first?, #iterate, #last, #last?, #next, #parent, #prev, #segment, #segmentn, #sequence, #successors, #zipper

Methods included from Inspect

#inspect

Constructor Details

#initialize(config, active) ⇒ StateMachine

Returns a new instance of StateMachine.



18
19
20
# File 'lib/stupidedi/parser/state_machine.rb', line 18

def initialize(config, active)
  @config, @active = config, active
end

Instance Attribute Details

#activeArray<Zipper::AbstractCursor<StateMachine::AbstractState>> (readonly)

Returns:



16
17
18
# File 'lib/stupidedi/parser/state_machine.rb', line 16

def active
  @active
end

#configConfig (readonly)

Returns:



13
14
15
# File 'lib/stupidedi/parser/state_machine.rb', line 13

def config
  @config
end

Class Method Details

.build(config, zipper = Zipper::Tree) ⇒ StateMachine

Returns:



54
55
56
# File 'lib/stupidedi/parser/state_machine.rb', line 54

def build(config, zipper = Zipper::Tree)
  StateMachine.new(config, InitialState.start(zipper).cons)
end

Instance Method Details

#copy(changes = {})



22
23
24
25
26
# File 'lib/stupidedi/parser/state_machine.rb', line 22

def copy(changes = {})
  StateMachine.new \
    changes.fetch(:config, @config),
    changes.fetch(:active, @active)
end

#pretty_print(q)

This method returns an undefined value.



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/stupidedi/parser/state_machine.rb', line 34

def pretty_print(q)
  q.text "StateMachine[#{@active.length}]"
  q.group 2, "(", ")" do
    q.breakable ""
    @active.each do |s|
      unless q.current_group.first?
        q.text ","
        q.breakable
      end
      q.pp s.node.zipper.node
    end
  end
end

#separatorsReader::Separators

Returns:



29
30
31
# File 'lib/stupidedi/parser/state_machine.rb', line 29

def separators
  @active.head.node.separators
end