Class: GhostWheel::Expression::LookAhead
- Inherits:
-
GhostWheel::Expression
- Object
- GhostWheel::Expression
- GhostWheel::Expression::LookAhead
- Defined in:
- lib/ghost_wheel/expression/look_ahead.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#negate ⇒ Object
(also: #negate?)
readonly
Returns the value of attribute negate.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(expression, negate = false) ⇒ LookAhead
constructor
A new instance of LookAhead.
- #uncached_parse(scanner, cache) ⇒ Object
Methods inherited from GhostWheel::Expression
Constructor Details
#initialize(expression, negate = false) ⇒ LookAhead
Returns a new instance of LookAhead.
6 7 8 9 |
# File 'lib/ghost_wheel/expression/look_ahead.rb', line 6 def initialize(expression, negate = false) @expression = expression @negate = negate end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
11 12 13 |
# File 'lib/ghost_wheel/expression/look_ahead.rb', line 11 def expression @expression end |
#negate ⇒ Object (readonly) Also known as: negate?
Returns the value of attribute negate.
11 12 13 |
# File 'lib/ghost_wheel/expression/look_ahead.rb', line 11 def negate @negate end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/ghost_wheel/expression/look_ahead.rb', line 28 def ==(other) super and @expression == other.expression and @negate == other.negate end |
#uncached_parse(scanner, cache) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ghost_wheel/expression/look_ahead.rb', line 14 def uncached_parse(scanner, cache) matched = nil scanner.transaction do matched = @expression.parse(scanner, cache) scanner.abort end if matched.is_a? FailedParseResult @negate ? EmptyParseResult.instance : matched else @negate ? FailedParseResult.instance : EmptyParseResult.instance end end |