Class: Rattler::Parsers::Assert
- Inherits:
-
Predicate
- Object
- Util::Node
- Parser
- Predicate
- Rattler::Parsers::Assert
- Defined in:
- lib/rattler/parsers/assert.rb
Overview
Assert
decorates a parser and succeeds or fails like the decorated parser but never consumes any input (zero-width positive lookahead).
Instance Method Summary collapse
-
#parse(scanner, rules, scope = ParserScope.empty) ⇒ Boolean
Succeed or fail like the decorated parser but do not consume any input and return
true
on success.
Methods inherited from Predicate
#capturing?, #capturing_decidable?, parsed
Methods included from Combining
#capturing?, #capturing_decidable?, #semantic?, #with_ws
Methods inherited from Parser
#&, #>>, #capturing?, #capturing_decidable?, #labeled?, #list, #one_or_more, #optional, parsed, #repeat, #semantic?, #sequence?, #skip, #variable_capture_count?, #with_ws, #zero_or_more, #|
Methods included from Runtime::ParserHelper
Methods inherited from Util::Node
#==, [], #[], #attrs, #can_equal?, #child, #children, #each, #empty?, #eql?, #initialize, #inspect, #method_missing, #name, #pretty_print, #pretty_print_cycle, #respond_to?, #same_contents?, #to_graphviz, #with_attrs, #with_attrs!, #with_children
Constructor Details
This class inherits a constructor from Rattler::Util::Node
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rattler::Util::Node
Instance Method Details
#parse(scanner, rules, scope = ParserScope.empty) ⇒ Boolean
Succeed or fail like the decorated parser but do not consume any input and return true
on success.
15 16 17 18 19 20 |
# File 'lib/rattler/parsers/assert.rb', line 15 def parse(scanner, rules, scope = ParserScope.empty) pos = scanner.pos result = (child.parse(scanner, rules, scope) && true) scanner.pos = pos result end |