Sha256: 43fdc33e6a9243c60845e39378d82561e9db35789b76364547081c2b0c85b7d5

Contents?: true

Size: 674 Bytes

Versions: 8

Compression:

Stored size: 674 Bytes

Contents

class Parslet::Atoms::Base
  
  # 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
  #
  def parse_with_debug str, opts={}
    parse str, opts
  rescue Parslet::ParseFailed => error
    puts error.cause.ascii_tree
  end

end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
swift-pyrite-0.1.1 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/lib/parslet/convenience.rb
swift-pyrite-0.1.0 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/lib/parslet/convenience.rb
parslet-1.7.1 lib/parslet/convenience.rb
parslet-1.7.0 lib/parslet/convenience.rb
parslet-1.6.2 lib/parslet/convenience.rb
parslet-1.6.1 lib/parslet/convenience.rb
parslet-1.6.0 lib/parslet/convenience.rb
parslet-1.5.0 lib/parslet/convenience.rb