Class: Rattler::Parsers::Skip
- Inherits:
-
Parser
- Object
- Util::Node
- Parser
- Rattler::Parsers::Skip
- Defined in:
- lib/rattler/parsers/skip.rb
Overview
Skip
decorates a parser to skip over what it matches without capturing the results
Class Method Summary collapse
Instance Method Summary collapse
-
#capturing? ⇒ Boolean
Always
false
. -
#parse(scanner, rules, scope = {}) ⇒ Boolean
If the decorated parser matches return
true
, otherwise return a false value. -
#skip ⇒ Object
A new parser that skips over what this parser matches.
-
#with_ws(ws) ⇒ Parser
Return a new parser that uses
ws
to skip whitespace before matching tokens.
Methods inherited from Parser
#&, #labeled?, #one_or_more, #optional, #variable_capture_count?, #zero_or_more, #|
Methods inherited from Util::Node
#==, [], #[], #attrs, #can_equal?, #child, #children, #each, #empty?, #eql?, #initialize, #inspect, #method_missing, #name, #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
Class Method Details
.parsed(results, *_) ⇒ Object
18 19 20 |
# File 'lib/rattler/parsers/skip.rb', line 18 def self.parsed(results, *_) #:nodoc: self[results.first] end |
Instance Method Details
#capturing? ⇒ Boolean
Always false
35 36 37 |
# File 'lib/rattler/parsers/skip.rb', line 35 def capturing? false end |
#parse(scanner, rules, scope = {}) ⇒ Boolean
If the decorated parser matches return true
, otherwise return a false value.
29 30 31 |
# File 'lib/rattler/parsers/skip.rb', line 29 def parse(scanner, rules, scope = {}) child.parse(scanner, rules, scope) && true end |
#skip ⇒ Object
Returns a new parser that skips over what this parser matches.
49 50 51 |
# File 'lib/rattler/parsers/skip.rb', line 49 def skip self end |
#with_ws(ws) ⇒ Parser
Return a new parser that uses ws
to skip whitespace before matching tokens.
44 45 46 |
# File 'lib/rattler/parsers/skip.rb', line 44 def with_ws(ws) child.with_ws(ws).skip end |