Class: Rsec::SeqOne

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

Overview

sequence combinator<br/> the result is the result of the parser at idx

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

#idxObject

Returns the value of attribute idx

Returns:

  • (Object)

    the current value of idx



17
18
19
# File 'lib/rsec/parsers/seq.rb', line 17

def idx
  @idx
end

#parsersObject

Returns the value of attribute parsers

Returns:

  • (Object)

    the current value of parsers



17
18
19
# File 'lib/rsec/parsers/seq.rb', line 17

def parsers
  @parsers
end

Instance Method Details

#_parse(ctx) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/rsec/parsers/seq.rb', line 20

def _parse ctx
  ret = INVALID
  parsers.each_with_index do |p, i|
    res = p._parse ctx
    return INVALID if INVALID[res]
    ret = res if i == idx
  end
  ret
end