Parslet 1.4.0

parslet is a Parsing Expression Grammar based[1] parser 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.

Installation:

gem install parslet

Synopsis:

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

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

Changes:

We’re continuing our tradition of aggressively curating the code to
better suit our needs:

  • Revised documentation. A few new API features have finally made it
    into the documentation. Examples in the documentation are now curated
    and run against the current code so that they really really work.

  • Optimistic parse: Parsing is two phase, with the first phase assuming
    there will be no errors. This yields ~ 20% speed improvement in the case
    where the parse succeeds. Also, internal error handling is now using
    tuples. This and other optimizations have yielded ~ 30% overall
    improvement. In SPEED!

  • Parslet::Source now doesn’t hold a StringIO, it directly holds the
    buffer to be parsed. Also: custom sources can be passed into a parse.

  • :reporter argument to parse, allowing to customize error reporting
    within wide boundaries. See issue #64 for a discussion. Included are two
    error reporters, one (default) with the existing error tree
    functionality, one reporting deepest errors as defined by the above
    ticket. See http://kschiess.github.com/parslet/tricks.html for a
    description of the reporter engines or run ‘examples/nested_errors.rb’
    and ‘examples/deepest_errors.rb’ to compare the methods.

! #error_tree and #cause removed from all of parslet. The
Parslet::ParseFailed exception now contains a #cause field that can be
asked for an #ascii_tree as before. Cleaner internal error handling, not
stateful in atoms anymore. Some parsers will see correct error
reporting for the first time. (issue #65) For this feature, we were able
to delete a lot of code, something we’re quite fond of.

  • VM engine removed.

Special thanks go to John M. who shook up existing structures just
enough for them to fall into place better. Run. Write a language today.

[1] Parsing expression grammar - Wikipedia