Class: Rsec::Branch

Inherits:
Unary
  • Object
show all
Defined in:
lib/rsec/parsers/misc.rb

Overview

branch combinator<br/> result in one of the members, or INVALID

Instance Attribute Summary

Attributes inherited from Unary

#some

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



76
77
78
79
80
81
82
83
84
# File 'lib/rsec/parsers/misc.rb', line 76

def _parse ctx
  save_point = ctx.pos
  some.each do |e|
    res = e._parse ctx
    return res unless INVALID[res]
    ctx.pos = save_point
  end
  INVALID
end