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

#semantic?, #with_ws

Methods inherited from Parser

#&, #>>, #labeled?, #list, #one_or_more, #optional, #repeat, #semantic?, #sequence?, #variable_capture_count?, #with_ws, #zero_or_more, #|

Methods included from Runtime::ParserHelper

#select_captures

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

Class Method Details

.parsed(results, *_) ⇒ Object



12
13
14
# File 'lib/rattler/parsers/skip.rb', line 12

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

Instance Method Details

#capturing?Boolean

Returns false.

Returns:

  • (Boolean)

    false

See Also:



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

def capturing?
  false
end

#capturing_decidable?Boolean

Returns true.

Returns:

  • (Boolean)

    true

See Also:



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

def capturing_decidable?
  true
end

#parse(*args) ⇒ Boolean

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

Parameters:

  • scanner (StringScanner)

    the scanner for the current parse

  • rules (RuleSet)

    the grammar rules being used for the current parse

  • scope (ParserScope)

    the scope of captured results

Returns:

  • (Boolean)

    true if the decorated parser matches at the parse position



23
24
25
# File 'lib/rattler/parsers/skip.rb', line 23

def parse(*args)
  child.parse(*args) && true
end

#skipSkip

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

Returns:

  • (Skip)

    a new parser that skips over what this parser matches



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

def skip
  self
end