Logo for page: index
Marpa
Last updated: Wed, 30 Apr 2025
Table of Contents
Marpa - A very brief overview
Important Marpa Links
Tutorials
Articles
Applications
Extensions
Libmarpa
Language interfaces
Perl Packages
Perl Module Demo Output

Marpa - A very brief overview
An overview of Marpa from its author, Jeffrey Kegler:

Marpa is a parsing algorithm. It is new, but very much
based on the prior work of Jay Earley, Joop Leo, John
Aycock and R. Nigel Horspool.

Marpa is intended to replace, and to go well beyond,
recursive descent and the yacc family of parsers.

Marpa is fast. It parses in linear time:

	o All grammar classes that recursive descent parses.

	o The grammar class that the yacc family parses.

	o In fact, all unambiguous grammars, as long as they
      are free of unmarked middle recursions.

	o Ambiguous grammars that are unions of a finite set
      of any of the above grammars.

Marpa is powerful. Marpa will parse anything that can be
written in BNF. This includes any mixture of left, right
and middle recursions.

Marpa is convenient. Unlike recursive descent, you do not
have to write a parser - Marpa generates one from BNF.
Unlike PEG or yacc, parser generation is unrestricted and
exact. Marpa converts any grammar which can be written as
BNF into a parser which recognizes everything in the
language described by that BNF, and which rejects everything
that is not in that language. The programmer is not forced
to make arbitrary choices while parsing. If a rule has
several alternatives, each alternative is evaluated for as
long as it might yield a valid parse.

Marpa is flexible. Like recursive descent, Marpa allows you
to stop and do your own custom processing. Unlike recursive
descent, Marpa makes available to you detailed information
about the parse so far - which rules and symbols have been
recognized, with their locations, and which rules and
symbols are expected next.
Important Marpa Links
The Marpa FAQ
The Marpa Papers - Introductory Material
Jeffrey Kegler's own Marpa website
Jeffrey Kegler's blog
The annotated index to Jeffrey Kegler's blog
The source code on github
The (now-closed) Google Group
Our archive of the Google Group (Marpa.Google.Group.2023.12.06.zip)
The IRC channel irc.freenode.net#marpa. Click to access backlog
The Youtube channel
Kollos: The next phase of Marpa's development

Tutorials
By Marpa's author:
The Marpa documentation contains a series of tutorials, starting at Marpa::R2's top-level page
Jeffrey has posted several tutorials to his blog
But an author can be at a disadvantage when writing a tutorial. He may know the subject too well, so ...
By Peter Stuifzand:
The Marpa Guide
By amon:
2013-06-26: Transforming Syntax
By Ron Savage:
A note about option combinations within Marpa's DSL

Articles
2015-11-11: Understanding Marpa-style action subs parameters
2015-04-28: An Overview of the Marpa Parser
2015-01-19: Marpa Praxis # 1: Briefly discuss MarpaX::Languages::SVG::Parser
2015-01-06: Fancy Matching of Delimited Text
2014-10-31: Disambiguating Simultaneous Events
2014-10-10: Conditional preservation of whitespace (Original: 2013-08-02)
2014-10-06: Using Marpa with an external tokenizer
2014-08-26: A New Marpa-based Parser for Graphviz
2014-02-03: A Marpa use case: JavaScript Regexp Implementation
Earley Parsing Explained
Marpa's speed claims
LL and LR Parsing
BNF
Domain-specific Language
Wikipedia's article on parsing
Abstract Syntax Trees

Applications
IBM Tivoli Monitoring Wonderful World of Situations
A Go code generator
Another Go code generator

Extensions
Grammar::Marpa
MarpaX::ASF::PFG - Prune Marpa::R2 Abstract Syntax Forest (ASFs) using Parse Forest Grammars (PFG)
MarpaX::Import - Import grammars into Marpa: BNF, EBNF, XBNF (W3C), Marpa's BNF
MarpaX::Parse
MarpaX::Repa
MarpaX::Simple
MarpaX::Simple::Rules

Libmarpa
Libmarpa - The C language parse engine
Libmarpa - The index for the docs
Libmarpa - The docs on one page

Language interfaces
cfg: A Rust library for manipulating context-free grammars
C++ docs
Go docs
Perl docs for Marpa::R2
XML processing (in C)
MarpaX::Database::Terminfo - Terminfo processing
MarpaX::Demo::JSONParser - Various grammars for JSON
MarpaX::Grammar::Parser - Parse Marpa grammars
MarpaX::Languages::C::AST - C processing
MarpaX::Languages::CommonMark::AST - CommonMark processing
MarpaX::Languages::ECMAScript::AST - ECMAScript processing
MarpaX::Languages::IDL::AST - OMG's IDL processing
MarpaX::Languages::Lua::Parser - Lua processing
MarpaX::Languages::PowerBuilder - PowerBuilder source parser based on Marpa
MarpaX::Languages::SQL2003::AST - SQL processing
MarpaX::Languages::SVG::Parser - SVG processing
MarpaX::Languages::XML::AST - Translate XML to an AST using Marpa
Protocol::Star::Linemode - Star POS lineprinter protocol
TAP::Spec::Parser - TAP (Test Anything Protocol) processing

Perl Packages
App::Datecalc
Catmandu
Creating a simple programming language using Marpa::R2 grammars
Filter data structures for 'partial responses,' Google style: Data-Partial-Google
Make marpaWrapperLua
Marpa parser for GO
Parser/generator for Marpa grammars in Go
Genealogy::Gedcom::Date - Parse GEDCOM dates in French r/German/Gregorian/Hebrew/Julian
Grammar::Marpa - Overload wrapper around Marpa::R2::Scanless
Graphics-GVG - Game Vector Graphics
GraphViz2::Marpa - Parse Graphviz DOT files
GraphViz2::Marpa::PathUtils - Finds stand-alone subgraphs, etc
JSON::Decode::Marpa - JSON parser using Marpa
Marpa::Simple::Lexer
MarpaX::AST
MarpaX::Database::Terminfo
MarpaX::Demo::JSONParser
MarpaX::Demo::SampleScripts
MarpaX::Grammar::GraphViz2
MarpaX::Grammar::Parser
MarpaX::Inline
MarpaX::Languages::C::AST
MarpaX::Languages::CommonMark::AST
MarpaX::Languages::Dash
MarpaX::Languages::ECMAScript::AST
MarpaX::Languages::IDL::AST - OMG's IDL
MarpaX::Languages::Lua::Parser
MarpaX::Languages::Perl::PackUnpack - Parse the templates used in pack() and unpack()
MarpaX::Languages::PowerBuilder - PowerBuilder source parser based on Marpa
MarpaX::Languages::SQL2003::AST - SQL processing
MarpaX::Languages::SVG::Parser
MarpaX::Languages::XML::AST - Translate XML to an AST using Marpa
MarpaX::Lex::Easy
MarpaX::Parser::Loader
MarpaX::Parser::Marpa
MarpaX::Parser::MarpaBase
MarpaX::Regex
MarpaX::RFC::RFC3629 - Marpa parsing of UTF-8 byte sequences as per RFC3629
MarpaX::RFC::RFC3986 - Parse Uniform Resource Identifiers (URIs)
MarpaX::RFC::RFC3987 - Parse Internationalized Resource Identifiers (IRIs)
MarpaX::Role::Parameterized::ResourceIdentifier::BNF - Resource Identifier BNF role
MarpaX::SGML
MarpaX::Tester
MarpaX::xPathLike
Math::ParseUnit - Parse quantities with units using Marpa
Notation::Based::Parsing - Marpa grammar for MathML
Protocol::Star::Linemode
Regexp::Parsertron
TAP::Spec::Parser
Task::LiveDVD::FrankfurtPM
Text::Balanced::Marpa
Text::Delimited::Marpa
X500::DN::Marpa

Perl Module Demo Output
These are all output from Ron's Marpa-oriented Perl modules.
GraphViz2::Marpa demos
GraphViz2::Marpa::PathUtils demos
MarpaX::Grammar::GraphViz2 demos
MarpaX::Languages::Dash demos
MarpaX::Languages::SVG::Parser: SVGs of BNFs
Top