Skip to content
A small PEG based parser library. See the Hacking page in the Wiki as well.
Ruby
Pull request Compare This branch is 312 commits behind kschiess:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
example
experiments
lib
spec
.gitignore
Gemfile
Gemfile.lock
Guardfile
HISTORY.txt
LICENSE
README
Rakefile
parslet.gemspec

README

INTRODUCTION

Parslet makes developing complex parsers easy. It does so by

* providing the best error reporting possible
* not generating reams of code for you to debug

Parslet takes the long way around to make your job easier. It allows for
incremental language construction. Often, you start out small, implementing
the atoms of your language first; _parslet_ takes pride in making this
possible.

Eager to try this out? Please see the associated web site:
http://kschiess.github.com/parslet

SYNOPSIS

  require 'parslet'
  include Parslet

  # Constructs a parser using a Parser Expression Grammar like DSL: 
  parser =  str('"') >> 
            (
              str('\\') >> any |
              str('"').absnt? >> any
            ).repeat.as(:string) >> 
            str('"')
  
  # Parse the string and capture parts of the interpretation (:string above)        
  tree = parser.parse('"This is a \\"String\\" in which you can escape stuff"')

  tree # => {:string=>"This is a \\\"String\\\" in which you can escape stuff"}

  # Here's how you can grab results from that tree:

  transform = Parslet::Transform.new do
    rule(:string => simple(:x)) { 
      puts "String contents: #{x}" }
  end
  transform.apply(tree)

COMPATIBILITY

This library should work with most rubies. I've tested it with MRI 1.8 
(except 1.8.6), 1.9, rbx-head, jruby. Please report as a bug if you encounter 
issues.

Note that due to Ruby 1.8 internals, Unicode parsing is not supported on that 
version. 

On Mac OS X Lion, ruby-1.8.7-p352 has been known to segfault. Use
ruby-1.8.7-p334 for better results.

STATUS 

At version 1.2.3 - See HISTORY.txt for changes.

(c) 2010 Kaspar Schiess
Something went wrong with that request. Please try again.