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
|
---
layout: layout
title: About
---
<pre class="sh_ruby"><code>
require 'parslet'
include Parslet
# Constructs a parser using a Parser Expression Grammar
parser = str('"') >>
(
str('\\').ignore >> any |
str('"').absent? >> any
).repeat.as(:string) >>
str('"')
result = parser.parse %Q("this is a valid \\"string\\"")
result # => {:string=>"this is a valid \"string\""@1}
</code></pre>
A small Ruby library for constructing parsers in the
"PEG":http://en.wikipedia.org/wiki/Parsing_expression_grammar (Parsing
Expression Grammar) fashion.
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? "Get started":get-started.html!
|