Class: Rattler::Parsers::Predicate

Inherits:
Parser show all
Includes:
Combining
Defined in:
lib/rattler/parsers/predicate.rb

Overview

A Predicate is a parser that either succeeds or fails and never consumes any input or captures any parse results.

Direct Known Subclasses

Assert, Disallow

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?, #skip, #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



11
12
13
# File 'lib/rattler/parsers/predicate.rb', line 11

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

Instance Method Details

#capturing?Boolean

Returns true if the parser returns parse results on success, or false if the parser simply returns true on success.

Returns:

  • (Boolean)

    true if the parser returns parse results on success, or false if the parser simply returns true on success



16
17
18
# File 'lib/rattler/parsers/predicate.rb', line 16

def capturing?
  false
end

#capturing_decidable?Boolean

true if it can be determined statically whether the parser returns parse results on success

Returns:

  • (Boolean)

    true if it can be determined statically whether the parser returns parse results on success



21
22
23
# File 'lib/rattler/parsers/predicate.rb', line 21

def capturing_decidable?
  true
end