Marpa is a parsing algorithm.
From the official Marpa website:
Marpa is fast. It parses in linear time:
- all the grammar classes that recursive descent parses;
- the grammar class that the yacc family parses;
- in fact, any unambiguous grammars, with a couple of exceptions that are not likely to be an issue in practice (see quibbles); and
- all ambiguous grammars that are unions of a finite set of any of the above grammars.
Add this to your application's
dependencies: marpa: github: omarroth/marpa
require "marpa" parser = Marpa::Parser.new grammar = <<-'END_BNF' :start ::= language language ::= number op_plus number number ~ [\d]+ op_plus ~ '+' :discard ~ whitespace whitespace ~ [\s]+ END_BNF input = "100 + 200" parser.parse(input, grammar) # => ["100", "+", "200"]
examples/ for a more thorough demonstration of this interface's capabilities, including a parser for JSON.
- Support for PCREs in lexing (see
- Speed guarantees of the original Marpa algorithm (see above).
- Supports ambiguous and null rules.
- Does not provide all parses of ambiguous input.
- Several other important features of the SLIF interface, on which this one is based.
- Fork it ( https://github.com/omarroth/marpa/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- omarroth Omar Roth - creator, maintainer