Class: Rsec::SeqOne_

Inherits:
Struct
  • Object
show all
Includes:
Parser
Defined in:
lib/rsec/parsers/seq.rb

Overview

skips skipper between tokens

Instance Attribute Summary collapse

Attributes included from Parser

#name

Instance Method Summary collapse

Methods included from Parser

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

Instance Attribute Details

#firstObject

Returns the value of attribute first

Returns:

  • (Object)

    the current value of first



51
52
53
# File 'lib/rsec/parsers/seq.rb', line 51

def first
  @first
end

#idxObject

Returns the value of attribute idx

Returns:

  • (Object)

    the current value of idx



51
52
53
# File 'lib/rsec/parsers/seq.rb', line 51

def idx
  @idx
end

#restObject

Returns the value of attribute rest

Returns:

  • (Object)

    the current value of rest



51
52
53
# File 'lib/rsec/parsers/seq.rb', line 51

def rest
  @rest
end

#skipperObject

Returns the value of attribute skipper

Returns:

  • (Object)

    the current value of skipper



51
52
53
# File 'lib/rsec/parsers/seq.rb', line 51

def skipper
  @skipper
end

Instance Method Details

#_parse(ctx) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rsec/parsers/seq.rb', line 54

def _parse ctx
  ret = INVALID

  res = first._parse ctx
  return INVALID if INVALID[res]
  ret = res if 0 == idx

  check = idx - 1
  rest.each_with_index do |p, i|
    return INVALID if INVALID[skipper._parse ctx]
    res = p._parse ctx
    return INVALID if INVALID[res]
    ret = res if i == check
  end
  ret
end