Class: Rsec::JoinEven

Inherits:
Binary
  • Object
show all
Defined in:
lib/rsec/parsers/join.rb,
lib/rsec/helpers.rb

Overview

keep only tokens

Instance Attribute Summary

Attributes inherited from Binary

#left, #right

Attributes included from Parser

#name

Instance Method Summary collapse

Methods included from Parser

#&, #*, #<<, #>>, #^, #cached, #eof, #fail, #inspect, #join, #map, #maybe, #parse, #parse!, #star, #|

Instance Method Details

#_parse(ctx) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rsec/parsers/join.rb', line 33

def _parse ctx
  e = left._parse ctx
  return INVALID if INVALID[e]
  ret = [e]
  loop do
    save_point = ctx.pos
    i = right._parse ctx
    if INVALID[i]
      ctx.pos = save_point
      break
    end

    t = left._parse ctx
    if INVALID[t]
      ctx.pos = save_point
      break
    end

    break if save_point == ctx.pos # stop if no advance, prevent infinite loop
    ret << t
  end # loop
  ret
end

#unbox(&p) ⇒ Object



379
380
381
# File 'lib/rsec/helpers.rb', line 379

def unbox &p
  Unbox[self].map p
end