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.
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.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.