Class: RParsec::PlusParser
- Inherits:
-
LookAheadSensitiveParser
- Object
- Parser
- LookAheadSensitiveParser
- RParsec::PlusParser
- Defined in:
- lib/rparsec/plus_parser.rb
Overview
:nodoc:
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) ⇒ PlusParser
constructor
A new instance of PlusParser.
- #plus(other) ⇒ Object
- #withLookahead(n) ⇒ 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, #some, #some_, #to_s, #token, #|
Methods included from Monad
#bind, #initMonad, #map, #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) ⇒ PlusParser
Returns a new instance of PlusParser.
6 7 8 9 |
# File 'lib/rparsec/plus_parser.rb', line 6 def initialize(alts, la = 1) super(la) @alts = alts end |
Instance Method Details
#_parse(ctxt) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rparsec/plus_parser.rb', line 10 def _parse ctxt ind = ctxt.index result = ctxt.result err = ctxt.error for p in @alts ctxt.reset_error ctxt.index = ind ctxt.result = result return true if p._parse(ctxt) return false unless visible(ctxt, ind) err = Failures.add_error(err, ctxt.error) end ctxt.error = err return false end |
#plus(other) ⇒ Object
28 29 30 |
# File 'lib/rparsec/plus_parser.rb', line 28 def plus other PlusParser.new(@alts.dup << other, @lookahead).tap { |p| p.name = name } end |
#withLookahead(n) ⇒ Object
25 26 27 |
# File 'lib/rparsec/plus_parser.rb', line 25 def withLookahead(n) PlusParser.new(@alts, n) end |