Skip to content
This repository

A small PEG based parser library. See the Hacking page in the Wiki as well.

Fetching latest commit…

Cannot retrieve the latest commit at this time


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

Eager to try this out? Please see the associated web site:


  require 'parslet'
  include Parslet

  # parslet parses strings
    parse('foo') # => "foo"@0

  # it matches character sets
  match['abc'].parse('a') # => "a"@0
  match['abc'].parse('b') # => "b"@0
  match['abc'].parse('c') # => "c"@0

  # and it annotates its output
    parse('foo') # => {:important_bit=>"foo"@0}

  # you can construct parsers with just a few lines
  quote = str('"')
  simple_string = quote >> (quote.absent? >> any).repeat >> quote

    parse('"Simple Simple Simple"') # => "\"Simple Simple Simple\""@0

  # or by making a fuss about it 
  class Smalltalk < Parslet::Parser
    root :smalltalk

    rule(:smalltalk) { statements }
    rule(:statements) { 
      # insert smalltalk parser here (outside of the scope of this readme)

  # and then'smalltalk')


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 

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

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


At version 1.4.0 - See HISTORY.txt for changes.

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