Class: RParsec::LookAheadSensitiveParser
- Defined in:
- lib/rparsec/look_ahead_sensitive_parser.rb
Overview
:nodoc:
Direct Known Subclasses
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
-
#initialize(la = 1) ⇒ LookAheadSensitiveParser
constructor
A new instance of LookAheadSensitiveParser.
- #lookahead(n) ⇒ Object
- #not(msg = "#{self} unexpected") ⇒ Object
- #visible(ctxt, n) ⇒ Object
Methods inherited from Parser
#>>, #atomize, #bindn, #catchp, #delimited, #delimited1, #expect, #followed, #fragment, #infixl, #infixn, #infixr, #lexeme, #many, #many_, #map, #mapn, #nested, #optional, #parse, #peek, #postfix, #prefix, #repeat, #repeat_, #separated, #separated1, #seq, #some, #some_, #to_s, #token, #|
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(la = 1) ⇒ LookAheadSensitiveParser
Returns a new instance of LookAheadSensitiveParser.
5 6 7 8 |
# File 'lib/rparsec/look_ahead_sensitive_parser.rb', line 5 def initialize(la = 1) super() @lookahead = la end |
Instance Method Details
#lookahead(n) ⇒ Object
12 13 14 15 16 |
# File 'lib/rparsec/look_ahead_sensitive_parser.rb', line 12 def lookahead(n) raise ArgumentError, "lookahead number #{n} should be positive" unless n > 0 return self if n == @lookahead withLookahead(n) end |
#not(msg = "#{self} unexpected") ⇒ Object
17 18 19 |
# File 'lib/rparsec/look_ahead_sensitive_parser.rb', line 17 def not(msg = "#{self} unexpected") NotParser.new(self, msg, @lookahead) end |
#visible(ctxt, n) ⇒ Object
9 10 11 |
# File 'lib/rparsec/look_ahead_sensitive_parser.rb', line 9 def visible(ctxt, n) ctxt.index - n < @lookahead end |