class Rattler::Parsers::Fail

Fail is a parser that always fails. It can be used to define more useful error messages.

Public Class Methods

[](type, message) click to toggle source

Create a new parser that always fails with message. The type should be one of :expr, :rule or :parse, indicating to simply fail, to cause its parse rule to fail, or to cause the entire parse to fail, respectively.

@param [Symbol] type :expr, :rule or :parse

@return [Fail] a new parser that always fails with message

# File lib/rattler/parsers/fail.rb, line 29
def self.[](type, message)
  self.new(:type => type, :message => message)
end

Public Instance Methods

capturing?() click to toggle source

@return false

# File lib/rattler/parsers/fail.rb, line 46
def capturing?
  false
end
parse(*_) click to toggle source

Always return false. The parser code generated for this parser should use message as the failure message, and should cause its parse rule to fail if type is :rule or cause the entire parse to fail if type is :parse

@param (see Match#parse)

@return false

# File lib/rattler/parsers/fail.rb, line 41
def parse(*_)
  false
end