Class: Rattler::Parsers::Disallow

Inherits:
Predicate show all
Defined in:
lib/rattler/parsers/disallow.rb

Overview

Disallow decorates a parser and succeeds if the decorated parser fails and fails if the parser succeeds and never consumes any input (zero-width negative lookahead).

Instance Method Summary collapse

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

#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

Instance Method Details

#parse(scanner, rules, scope = ParserScope.empty) ⇒ Boolean

Succeed and return true if and only if decorated parser fails. Never consumes any input.

Returns:

  • (Boolean)

    true if the decorated parser fails



16
17
18
19
20
21
# File 'lib/rattler/parsers/disallow.rb', line 16

def parse(scanner, rules, scope = ParserScope.empty)
  pos = scanner.pos
  result = !child.parse(scanner, rules, scope)
  scanner.pos = pos
  result
end