D★Parse

D★Parse is a parser combinator library for Ruby.

STATUS: Experimental. Pre-alpha. Use at your own risk.

Example

Here is a parser for a series of numbers:

require 'd-parse'

module Grammar
  extend DParse::DSL

  DIGIT = char_in('0'..'9')

  ROOT =
    seq(
      intersperse(
        repeat(DIGIT).capture.map { |d| d.to_i(10) },
        char(',').ignore,
      ).compact,
      eof,
    ).first
end

res = Grammar::ROOT.apply("1,2,100,582048,07,09")
case res
when DParse::Success
  p res.data
when DParse::Failure
  $stderr.puts res.pretty_message
  exit 1
end

Parsers

Special modifiers:

To do

As mentioned above, this software is in an early state, and still lacks many features. It is not yet a fully functional parser combinator library, but it’ll hopefully get there.

Commit message conventions

As an experiment, I’m going to use commit message conventions slightly adapted from {Angular.js}[https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md]’s.

<type>(<scope>): <subject>
<BLANK LINE>
<body>

The following types are supported:

The following scopes are supported:

The following rules apply to the subject: