[ANN] parslet 1.0 - a PEG parser library

K

Kaspar Schiess

parslet is a Parsing Expression Grammar based[1] parser generator
library. Uff. Now that is out of our system, here goes what it really
does: It makes writing parsers pleasant for the rest of us. No code
generation, clear access to data, unit testable.

* http://kschiess.github.com/parslet/index.html
* https://github.com/kschiess/parslet

Installation:

gem install parslet

Changes:

This hasn't ever been publicly announced, so that is the real big change.

Synopsis:

require 'parslet'
class Mini < Parslet::parser
rule:)integer) { match('[0-9]').repeat(1) }
root:)integer)
end

Mini.new.parse("132432") # => 132432

Please, ladies and gents, amuse yourselves!

[1] http://en.wikipedia.org/wiki/Parsing_expression_grammar
 
R

Ryan Davis

parslet is a Parsing Expression Grammar based[1] parser generator =
library. Uff. Now that is out of our system, here goes what it really =
does: It makes writing parsers pleasant for the rest of us. No code =
generation, clear access to data, unit testable.
=20
* http://kschiess.github.com/parslet/index.html
* https://github.com/kschiess/parslet
=20
Installation:
=20
gem install parslet
=20
Changes:
=20
This hasn't ever been publicly announced, so that is the real big = change.
=20
Synopsis:
=20
require 'parslet'
class Mini < Parslet::parser
rule:)integer) { match('[0-9]').repeat(1) }
root:)integer)
end
=20
Mini.new.parse("132432") # =3D> 132432

Cool!

Questions:

+ Any performance benchmarks?

+ Does this PEG support left recursion?

+ I assume with it subclassing Parslet::parser that it does support =
language extension via further subclassing... But does that also imply =
that it can't support composition? I've usually seen that via multiple =
inheritance, and we'd usually do it via modules in ruby.

AH! I see that Parslet is a module and provides at least some of the =
grammar API.=
 
K

Kaspar Schiess

+ Any performance benchmarks?

Official ones, no. Working with it: I just might have gotten the
impression that there is room for improvement. (slow!) This is certainly
the next thing on the menu. For example, it uses exceptions heavily
which isn't the fastest thing to do. Can be and will be changed.
+ Does this PEG support left recursion?
Not yet. (Or only in the limited fashion, after a grammar
transformation) Cool you mention the possibility to me, might just add
that.
+ I assume with it subclassing Parslet::parser that it does support language extension via further subclassing... But does that also imply that it can't support composition? I've usually seen that via multiple inheritance, and we'd usually do it via modules in ruby.

AH! I see that Parslet is a module and provides at least some of the grammar API.

That's a complicated topic ;) Parser rules are just methods on a class,
so go ahead and use modules, classes and other tricks any way you like
it. Like in example/ip_address.rb.

The documentation tries to simplify that for the general case. And I
have yet to see a sample of composition that is really useful (in the
sense of orthogonality of pieces).

Also, don't dig too hard, hidden features lurking to bite you ;)

regards,
kaspar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top