Class: Fabulator::Grammar::Expr::LookAhead
- Inherits:
-
Object
- Object
- Fabulator::Grammar::Expr::LookAhead
- Defined in:
- lib/fabulator/grammar/expr/look_ahead.rb
Instance Method Summary collapse
-
#initialize(sequence) ⇒ LookAhead
constructor
A new instance of LookAhead.
- #name ⇒ Object
- #parse(source) ⇒ Object
Constructor Details
#initialize(sequence) ⇒ LookAhead
Returns a new instance of LookAhead.
5 6 7 |
# File 'lib/fabulator/grammar/expr/look_ahead.rb', line 5 def initialize(sequence) @sequence = sequence end |
Instance Method Details
#name ⇒ Object
9 10 11 |
# File 'lib/fabulator/grammar/expr/look_ahead.rb', line 9 def name nil end |
#parse(source) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/fabulator/grammar/expr/look_ahead.rb', line 13 def parse(source) ret = false source.attempt do |c| ret = @sequence.parse(c) raise Fabulator::Grammar::RejectParse end raise Fabulator::Grammar::RejectParse unless ret end |