Class: Rattler::Parsers::Skip

Inherits:
Parser show all
Includes:
Combining
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

Methods included from Combining

#with_ws

Methods inherited from Parser

#&, #labeled?, #one_or_more, #optional, #variable_capture_count?, #with_ws, #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



19
20
21
# File 'lib/rattler/parsers/skip.rb', line 19

def self.parsed(results, *_) #:nodoc:
  self[results.first]
end

Instance Method Details

#capturing?Boolean

Always false

Returns:

  • (Boolean)

    false



36
37
38
# File 'lib/rattler/parsers/skip.rb', line 36

def capturing?
  false
end

#parse(scanner, rules, scope = {}) ⇒ Boolean

If the decorated parser matches return true, otherwise return a false value.

Returns:

  • (Boolean)

    true if the decorated parser matches at the parse position



30
31
32
# File 'lib/rattler/parsers/skip.rb', line 30

def parse(scanner, rules, scope = {})
  child.parse(scanner, rules, scope) && true
end

#skipObject

Returns a new parser that skips over what this parser matches.

Returns:

  • a new parser that skips over what this parser matches



41
42
43
# File 'lib/rattler/parsers/skip.rb', line 41

def skip
  self
end