Class Parslet::Cause
In: lib/parslet/cause.rb
Parent: Object

Represents a cause why a parse did fail. A lot of these objects are constructed - not all of the causes turn out to be failures for the whole parse.

Methods

ascii_tree   children   format   new   raise   to_s  

Attributes

message  [R]  @return [String, Array] A string or an array of message pieces that
  provide failure information. Use #to_s to get a formatted string.
pos  [R]  Location of the error.

@return [Fixnum] Position where the error happened. (character offset)

source  [R]  @return [Parslet::Source] Source that was parsed when this error
  happend. Mainly used for line number information.

Public Class methods

Appends ‘at line LINE char CHAR’ to the string given. Use pos to override the position of the source. This method returns an object that can be turned into a string using to_s.

@param source [Parslet::Source] source that was parsed when this error

  happened

@param pos [Fixnum] position of error @param str [String, Array<String>] message parts @param children [Array<Parslet::Cause>] child nodes for this error tree @return [Parslet::Cause] a new instance of {Parslet::Cause}

Public Instance methods

Returns an ascii tree representation of the causes of this node and its children.

When this cause is part of a tree of error causes: child nodes for this node. Very often carries the reasons for this cause.

@return [Array<Parslet::Cause>] A list of reasons for this cause.

Signals to the outside that the parse has failed. Use this in conjunction with .format for nice error messages.

[Validate]