Class: Stupidedi::Parser::IdentifierStack::ST

Inherits:
Object
  • Object
show all
Defined in:
lib/stupidedi/parser/identifier_stack.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, sequence) ⇒ ST

Returns a new instance of ST.



167
168
169
170
171
# File 'lib/stupidedi/parser/identifier_stack.rb', line 167

def initialize(parent, sequence)
  @parent, @id = parent, sequence.value
  @hl_sequence = Sequence.new(0)
  @lx_sequence = Sequence.new(0)
end

Instance Method Details

#count(builder) ⇒ Integer

Number of Included Segments (SE01)

Returns:

  • (Integer)


188
189
190
191
192
193
194
195
196
197
198
# File 'lib/stupidedi/parser/identifier_stack.rb', line 188

def count(builder)
  m = Either.success(builder.machine)

  while m.defined?
    if m.flatmap(&:segment).map{|s| s.node.id == :ST }.fetch(false)
      return m.flatmap{|n| n.distance(builder.machine) }.fetch(0) + 2
    else
      m = m.flatmap(&:parent)
    end
  end
end

#hl



177
178
179
# File 'lib/stupidedi/parser/identifier_stack.rb', line 177

def hl
  HL.new(self, @hl_sequence.succ!, @lx_sequence)
end

#id



173
174
175
# File 'lib/stupidedi/parser/identifier_stack.rb', line 173

def id
  "%04d" % @id
end

#lx



181
182
183
# File 'lib/stupidedi/parser/identifier_stack.rb', line 181

def lx
  @lx_sequence.succ!.value
end

#pop



204
205
206
207
# File 'lib/stupidedi/parser/identifier_stack.rb', line 204

def pop
  warn "DEPRECATION WARNING: IdentifierStack#pop is deprecated, use pop_st (when removing an ST identifier from the stack)"
  pop_st
end

#pop_st



200
201
202
# File 'lib/stupidedi/parser/identifier_stack.rb', line 200

def pop_st
  @parent
end