Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 52 lines (36 sloc) 1.396 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
INTRODUCTION

Parslet makes developing complex parsers easy. It does so by

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

Parslet takes the long way around to make <b>your job</b> 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(%Q{
    "This is a \\"String\\" in which you can escape stuff"
  }.strip)

  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 (method 2): #{x}" }
  end
  transform.apply(tree)

COMPATIBILITY

This library should work with both ruby 1.8 and ruby 1.9.

STATUS

one dot oh.

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