Class: RParsec::AltParser
- Inherits:
-
LookAheadSensitiveParser
- Object
- Parser
- LookAheadSensitiveParser
- RParsec::AltParser
- Defined in:
- lib/rparsec/parsers.rb
Constant Summary
Constants inherited from Parser
Constants included from Functors
Functors::And, Functors::At, Functors::BitAnd, Functors::Call, Functors::Compare, Functors::Dec, Functors::Div, Functors::Eq, Functors::Feed, Functors::Fst, Functors::Ge, Functors::Gt, Functors::Id, Functors::Idn, Functors::Inc, Functors::Le, Functors::Lt, Functors::Match, Functors::Minus, Functors::Mod, Functors::Mul, Functors::Ne, Functors::Neg, Functors::Not, Functors::Or, Functors::Plus, Functors::Power, Functors::Snd, Functors::Succ, Functors::To_a, Functors::To_f, Functors::To_i, Functors::To_s, Functors::To_sym, Functors::Union, Functors::Xor
Instance Attribute Summary
Attributes inherited from Parser
Attributes included from Monad
Instance Method Summary collapse
- #_parse(ctxt) ⇒ Object
-
#initialize(alts, la = 1) ⇒ AltParser
constructor
A new instance of AltParser.
- #withLookahead(n) ⇒ Object
- #|(other) ⇒ Object
Methods inherited from LookAheadSensitiveParser
Methods inherited from Parser
#>>, #atomize, #bindn, #catchp, #delimited, #delimited1, #expect, #followed, #fragment, #infixl, #infixn, #infixr, #lexeme, #lookahead, #many, #many_, #map, #mapn, #nested, #not, #optional, #parse, #peek, #postfix, #prefix, #repeat, #repeat_, #separated, #separated1, #seq, #setName, #some, #some_, #to_s, #token
Methods included from Signature
Methods included from DefHelper
#def_ctor, #def_mutable, #def_readable
Methods included from Monad
#bind, #initMonad, #map, #plus, #seq, #value
Methods included from Functors
#compose, #const, #curry, #flip, make_curry, make_reverse_curry, #nth, #power, #repeat, #reverse_curry, #reverse_uncurry, #uncurry
Constructor Details
#initialize(alts, la = 1) ⇒ AltParser
Returns a new instance of AltParser.
190 191 192 193 |
# File 'lib/rparsec/parsers.rb', line 190 def initialize(alts, la = 1) super(la) @alts, @lookahead = alts, la end |
Instance Method Details
#_parse(ctxt) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/rparsec/parsers.rb', line 194 def _parse ctxt ind, result, err = ctxt.index, ctxt.result, ctxt.error err_ind, err_pos = -1, -1 for p in @alts ctxt.reset_error ctxt.index, ctxt.result = ind, result return true if p._parse(ctxt) if ctxt.error.index > err_pos err, err_ind, err_pos = ctxt.error, ctxt.index, ctxt.error.index end end ctxt.index, ctxt.error = err_ind, err return false end |
#withLookahead(n) ⇒ Object
208 209 210 |
# File 'lib/rparsec/parsers.rb', line 208 def withLookahead(n) AltParser.new(@alts, n) end |
#|(other) ⇒ Object
211 212 213 |
# File 'lib/rparsec/parsers.rb', line 211 def | other AltParser.new(@alts.dup << autobox_parser(other)).setName(name) end |