Class | Parslet::Atoms::Base |
In: |
lib/parslet/convenience.rb
lib/parslet/atoms/base.rb lib/parslet/atoms/visitor.rb |
Parent: | Object |
Base class for all parslets, handles orchestration of calls and implements a lot of the operator and chaining methods.
Also see Parslet::Atoms::DSL chaining parslet atoms together.
Error tree returns what went wrong here plus what went wrong inside subexpressions as a tree. The error stored for this node will be equal to cause.
Given a string or an IO object, this will attempt a parse of its contents and return a result. If the parse fails, a Parslet::ParseFailed exception will be thrown.
Packages the common idiom
begin tree = parser.parse('something') rescue Parslet::ParseFailed => error puts error puts parser.error_tree end
into a convenient method.
Usage:
require 'parslet' require 'parslet/convenience' class FooParser < Parslet::Parser rule(:foo) { str('foo') } root(:foo) end FooParser.new.parse_with_debug('bar')