PEGTL - Parsing Expression Grammar Template Library

  •        162

The Parsing Expression Grammar Template Library (PEGTL) is a zero-dependency C++ header-only parser combinator library for creating parsers according to a Parsing Expression Grammar (PEG). Grammars are written as regular C++ code, created with template programming (not template meta programming), i.e. nested template instantiations that naturally correspond to the inductive definition of PEGs (and other parser-combinator approaches).



Related Projects

rust-peg - Parsing Expression Grammar (PEG) parser generator for Rust

  •    Rust

This is a simple parser generator based on Parsing Expression Grammars. Please see the release notes for updates.

pigeon - Command pigeon generates parsers in Go from a PEG grammar.

  •    Go

The pigeon command generates parsers based on a parsing expression grammar (PEG). Its grammar and syntax is inspired by the PEG.js project, while the implementation is loosely based on the parsing expression grammar for C# 3.0 article. It parses Unicode text encoded in UTF-8. See the godoc page for detailed usage. Also have a look at the Pigeon Wiki for additional information about Pigeon and PEG in general.

peg - Peg, Parsing Expression Grammar, is an implementation of a Packrat parser generator.

  •    Go

Peg, Parsing Expression Grammar, is an implementation of a Packrat parser generator. A Packrat parser is a descent recursive parser capable of backtracking. The generated parser searches for the correct parsing of the input.

parboiled2 - A macro-based PEG parser generator for Scala 2.10+

  •    Scala

parboiled2 is a Scala 2.11+ library enabling lightweight and easy-to-use, yet powerful, fast and elegant parsing of arbitrary input text. It implements a macro-based parser generator for Parsing Expression Grammars (PEGs), which runs at compile time and translates a grammar rule definition (written in an internal Scala DSL) into corresponding JVM bytecode.PEGs are an alternative to Context-Free Grammars (CFGs) for formally specifying syntax, they make a good replacement for regular expressions and have some advantages over the "traditional" way of building parsers via CFGs (like not needing a separate lexer/scanner phase).

Pegged - A Parsing Expression Grammar (PEG) module, using the D programming language.

  •    D

Pegged is a parsing expression grammar (PEG) generator implemented in the D programming language. The idea is to give the generator a PEG, with the syntax presented in the reference article . From this grammar definition a set of related parsers will be created, to be used at runtime or compile time.

language - A fast PEG parser written in JavaScript with first class errors

  •    Objective-J

Language.js is an experimental new parser based on PEG (Parsing Expression Grammar), with the special addition of the "naughty OR" operator to handle errors in a unique new way. It makes use of memoization to achieve linear time parsing speed, and support for automatic cut placement is coming to maintain mostly constant space as well (for a discussion of cut operators see: The most unique addition Language.js makes to PEG is how it handles errors. No parse ever fails in Language.js, instead SyntaxErrorNodes are placed into the resultant tree. This makes it trivial to do things like write syntax highlighters that have live error reporting. This also means that Language.js is very competent at handling multiple errors (as opposed to aborting on the first one that is reached).


  •    Python

The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the traditional lex/yacc approach, or the use of regular expressions. The pyparsing module provides a library of classes that client code uses to construct the grammar directly in Python code. The Python representation of the grammar is quite readable, owing to the self-explanatory class names, and the use of '+', '|' and '^' operator definitions.

rang - A Minimal, Header only Modern c++ library for terminal goodies 💄✨

  •    C++

rang only depends on C++ standard library, unistd.h system header on unix and windows.h & io.h system headers on windows based systems. In other words, you don't need any 3rd party dependencies. rang is a single header-only library. Put rang.hpp in the include folder directly into the project source tree or somewhere reachable from your project.

treetop - A Ruby-based parsing DSL based on parsing expression grammars.

  •    Ruby

Languages can be split into two components, their syntax and their semantics. It's your understanding of English syntax that tells you the stream of words "Sleep furiously green ideas colorless" is not a valid sentence. Semantics is deeper. Even if we rearrange the above sentence to be "Colorless green ideas sleep furiously", which is syntactically correct, it remains nonsensical on a semantic level. With Treetop, you'll be dealing with languages that are much simpler than English, but these basic concepts apply. Your programs will need to address both the syntax and the semantics of the languages they interpret. Treetop equips you with powerful tools for each of these two aspects of interpreter writing. You'll describe the syntax of your language with a parsing expression grammar. From this description, Treetop will generate a Ruby parser that transforms streams of characters written into your language into abstract syntax trees representing their structure. You'll then describe the semantics of your language in Ruby by defining methods on the syntax trees the parser generates.

parsimonious - The fastest pure-Python PEG parser I can muster

  •    Python

Parsimonious aims to be the fastest arbitrary-lookahead parser written in pure Python—and the most usable. It's based on parsing expression grammars (PEGs), which means you feed it a simplified sort of EBNF notation. Parsimonious was designed to undergird a MediaWiki parser that wouldn't take 5 seconds or a GB of RAM to do one page, but it's applicable to all sorts of languages. You can have forward references and even right recursion; it's all taken care of by the grammar compiler. The first rule is taken to be the default start symbol, but you can override that.

peg-markdown - An implementation of markdown in C, using a PEG grammar

  •    C

This is an implementation of John Gruber's markdown in C. It uses a parsing expression grammar (PEG) to define the syntax. This should allow easy modification and extension. It currently supports output in HTML, LaTeX, ODF, or groff_mm formats, and adding new formats is relatively easy. Both a library and a standalone program are provided.

treetop - A Ruby-based parsing DSL based on parsing expression grammars.

  •    Ruby

A Ruby-based parsing DSL based on parsing expression grammars.

neotoma - Erlang library and packrat parser-generator for parsing expression grammars.

  •    Erlang

Neotoma is a packrat parser-generator for Erlang for Parsing Expression Grammars (PEGs). It consists of a parsing-combinator library with memoization routines, a parser for PEGs, and a utility to generate parsers from PEGs. It is inspired by treetop, a Ruby library with similar aims, and parsec, the parser-combinator library for Haskell. Neotoma is licensed under the MIT License (see LICENSE).

doctest - The fastest feature-rich C++11 single-header testing framework for unit tests and TDD

  •    C++

doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of magnitude) and runtime compared to other feature-rich alternatives. It brings the ability of compiled languages such as D / Rust / Nim to have tests written directly in the production code by providing a fast, transparent and flexible test runner with a clean interface. The framework is and will stay free but needs your support to sustain its development. There are lots of new features and maintenance to do. If you work for a company using doctest or have the means to do so, please consider financial support. Monthly donations via Patreon and one-offs via PayPal.

eu.h8me.Parsing - (G)LR parsing/lexing library for .NET


Library implementing a regular expression based lexer and LR(1) based parser generator, using inline code to define lexer and grammar rules. The generated parser uses a GLR parsing engine to allow for ambiguous grammars.

gsl-lite - A single-file header-only version of ISO C++ Guideline Support Library (GSL) for C++98, C++11 and later

  •    C++

GSL Lite is based on the Microsoft Guidelines Support Library (GSL). gsl-lite is a single-file header-only variant of Microsoft's implementation of the Guidelines Support Library (GSL) adapted for C++98, C++03. It should also work when compiled as C++11, C++14, C++17.

compile-time-regular-expressions - A Compile time PCRE (almost) compatible regular expression matcher

  •    C++

Fast compile-time regular expression with support for matching/searching/capturing in compile-time or runtime. You can use single header version from directory single-header. This header can be regenerated with make single-header.

pegkit - 'Parsing Expression Grammar' toolkit for Cocoa/Objective-C

  •    Objective-C

PEGKit is a 'Parsing Expression Grammar' toolkit for iOS and OS X written by Todd Ditchendorf in Objective-C and released under the MIT Open Source License. Always use the Xcode Workspace PEGKit.xcworkspace, NOT the Xcode Project.

canopy - A parser compiler for Java, JavaScript, Python, Ruby

  •    Javascript

Canopy is a parser compiler targeting Java, JavaScript, Python and Ruby. It takes a file describing a parsing expression grammar and compiles it into a parser module in the target language. The generated parsers have no runtime dependency on Canopy itself. For usage documentation see

pest - The Elegant Parser

  •    Rust

pest is a PEG parser with simplicity and speed in mind. This is then saved in a .pest grammar file and is never mixed up with Rust code which results in an always up-to-date formal definition of the grammar which is very easy to maintain.

We have large collection of open source products. Follow the tags from Tag Cloud >>

Open source products are scattered around the web. Please provide information about the open source projects you own / you use. Add Projects.