Parslet 1.2 - a PEG parser library

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.

Installation:

gem install parslet

Changes:

  • All parsers are now parser atoms as well. Not only can you freely
    combine atoms, you can mix in parsers! Example:

    str(‘ip:’) >> IpParser.new >> str(‘;’)

  • Parslet now returns slices instead of strings. Slices are strings
    that retain original source offsets and are printed as “string”@0.
    This allows line and column information to be accessed in later
    stages: See Parslet::Slice for details.

  • #prsnt? and #absnt? are now deprecated. Please use only #present? and
    #absent

Synopsis:

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

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

Go wild. Write that compiler!

[1] Parsing expression grammar - Wikipedia

Thanks for your continued work on this, Kaspar!

Jos


Peace cannot be achieved through violence, it can only be attained
through
understanding.

On Wed, Mar 9, 2011 at 6:06 AM, Kaspar S. [email protected] wrote:

  • All parsers are now parser atoms as well. Not only can you freely
    combine atoms, you can mix in parsers! Example:

Nifty!

Kaspar S. wrote in post #986429:

  • #prsnt? and #absnt? are now deprecated.
    Please use only #present? and #absent

Hurray for improved readability! This is a good change. :slight_smile: