Class: Parslet::Atoms::Base

### Home Classes Methods

### In Files

- lib/parslet/atoms/visitor.rb
- lib/parslet/convenience.rb

### Parent

Object

### Methods

- #accept
- #parse_with_debug

### Files

- README

### Class/Module Index

Quicksearch

- Parslet
- Parslet::Atoms
- Parslet::Atoms::Alternative
- Parslet::Atoms::Base
- Parslet::Atoms::CanFlatten
- Parslet::Atoms::Capture
- Parslet::Atoms::Context
- Parslet::Atoms::DSL
- Parslet::Atoms::Dynamic
- Parslet::Atoms::Entity
- Parslet::Atoms::Lookahead
- Parslet::Atoms::Named
- Parslet::Atoms::Precedence
- Parslet::Atoms::Re
- Parslet::Atoms::Repetition
- Parslet::Atoms::Scope
- Parslet::Atoms::Sequence
- Parslet::Atoms::Str
- Parslet::Cause
- Parslet::ClassMethods
- Parslet::DelayedMatchConstructor
- Parslet::ErrorReporter
- Parslet::ErrorReporter::Deepest
- Parslet::ErrorReporter::Tree
- Parslet::Expression
- Parslet::Expression::Treetop
- Parslet::Expression::Treetop::Parser
- Parslet::Expression::Treetop::Transform
- Parslet::ParseFailed
- Parslet::Parser
- Parslet::Parser::PrettyPrinter
- Parslet::Parser::Visitors
- Parslet::Parser::Visitors::Citrus
- Parslet::Parser::Visitors::Treetop
- Parslet::Pattern
- Parslet::Pattern::SequenceBind
- Parslet::Pattern::SimpleBind
- Parslet::Pattern::SubtreeBind
- Parslet::Scope
- Parslet::Scope::Binding
- Parslet::Scope::NotFound
- Parslet::Slice
- Parslet::Source
- Parslet::Source::LineCache
- Parslet::Source::RangeSearch
- Parslet::Transform
- Parslet::Transform::Context

No matching classes.

# Parslet::Atoms::Base

### Public Instance Methods

accept(visitor) click to toggle source

    # File lib/parslet/atoms/visitor.rb, line 7
    def accept(visitor)
      raise NotImplementedError, "No #accept method on #{self.class.name}."
    end

parse_with_debug(str, opts={}) click to toggle source

Packages the common idiom

    begin
      tree = parser.parse('something')
    rescue Parslet::ParseFailed => error
      puts parser.cause.ascii_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')

@see Parslet::Atoms::Base#parse

    # File lib/parslet/convenience.rb, line 27
    def parse_with_debug str, opts={}
      parse str, opts
    rescue Parslet::ParseFailed => error
      puts error.cause.ascii_tree
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.