All Projects → taocpp → Pegtl

taocpp / Pegtl

Licence: mit
Parsing Expression Grammar Template Library

Programming Languages

cpp
1120 projects
cpp11
221 projects
cpp17
186 projects
grammar
57 projects

Projects that are alternatives of or similar to Pegtl

ParsecSharp
The faster monadic parser combinator library for C#
Stars: ✭ 23 (-98.22%)
Mutual labels:  parsing, parser-combinators, peg
Lug
Parsing expression grammar (PEG) embedded domain specific language and parsing machine for C++17
Stars: ✭ 44 (-96.6%)
Mutual labels:  parser-combinators, peg, parsing
Pom
PEG parser combinators using operator overloading without macros.
Stars: ✭ 310 (-76.06%)
Mutual labels:  parser-combinators, peg, parsing
chumsky
A parser library for humans with powerful error recovery.
Stars: ✭ 740 (-42.86%)
Mutual labels:  parser-combinators, peg
parser-combinators
Lightweight package providing commonly useful parser combinators
Stars: ✭ 41 (-96.83%)
Mutual labels:  parsing, parser-combinators
latex2unicode
Convert LaTeX markup to Unicode (in Scala and Java)
Stars: ✭ 28 (-97.84%)
Mutual labels:  parsing, peg
cppcombinator
parser combinator and AST generator in c++17
Stars: ✭ 20 (-98.46%)
Mutual labels:  parsing, peg
Pidgin
C#'s fastest parser combinator library
Stars: ✭ 469 (-63.78%)
Mutual labels:  parser-combinators, parsing
Cpp Peglib
A single file C++ header-only PEG (Parsing Expression Grammars) library
Stars: ✭ 435 (-66.41%)
Mutual labels:  peg, parsing
Scala Parser Combinators
simple combinator-based parsing for Scala. formerly part of the Scala standard library, now a separate community-maintained module
Stars: ✭ 523 (-59.61%)
Mutual labels:  parser-combinators, parsing
Comby
A tool for structural code search and replace that supports ~every language.
Stars: ✭ 912 (-29.58%)
Mutual labels:  parser-combinators, parsing
Pyparsing
Python library for creating PEG parsers
Stars: ✭ 1,052 (-18.76%)
Mutual labels:  parser-combinators, parsing
Myna Parser
Myna Parsing Library
Stars: ✭ 69 (-94.67%)
Mutual labels:  parser-combinators, peg
ohm-editor
An IDE for the Ohm language (JavaScript edition)
Stars: ✭ 78 (-93.98%)
Mutual labels:  parsing, peg
loquat
Monadic parser combinators for JavaScript / TypeScript
Stars: ✭ 47 (-96.37%)
Mutual labels:  parsing, parser-combinators
Angstrom
Parser combinators built for speed and memory efficiency
Stars: ✭ 434 (-66.49%)
Mutual labels:  parser-combinators, parsing
Parsing With Haskell Parser Combinators
🔍 A step-by-step guide to parsing using Haskell parser combinators.
Stars: ✭ 72 (-94.44%)
Mutual labels:  parser-combinators, parsing
arborist
Arborist is a PEG parser that supports left-associative left recursion
Stars: ✭ 17 (-98.69%)
Mutual labels:  parsing, peg
pe
Fastest general-purpose parsing library for Python with a familiar API
Stars: ✭ 21 (-98.38%)
Mutual labels:  parsing, peg
Rust Peg
Parsing Expression Grammar (PEG) parser generator for Rust
Stars: ✭ 836 (-35.44%)
Mutual labels:  peg, parsing

Welcome to the PEGTL

Windows CI macOS CI Linux CI Android CI
clang-analyze clang-tidy Sanitizer CodeQL Code Coverage

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).

Documentation

Contact

Join us on Discord

For questions and suggestions regarding the PEGTL, success or failure stories, and any other kind of feedback, please feel free to join our Discord server, open a discussion, an issue or a pull request on GitHub or contact the authors at taocpp(at)icemx.net.

Introduction

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).

A comprehensive set of parser rules that can be combined and extended by the user is included, as are mechanisms for debugging grammars, and for attaching user-defined actions to grammar rules. Here is an example of how a PEG grammar rule is implemented as C++ class with the PEGTL.

// PEG rule for integers consisting of a non-empty
// sequence of digits with an optional sign:

// sign ::= '+' / '-'
// integer ::= sign? digit+

// The same parsing rule implemented with the PEGTL:

using namespace tao::pegtl;

struct sign : one< '+', '-' > {};
struct integer : seq< opt< sign >, plus< digit > > {};

PEGs are superficially similar to Context-Free Grammars (CFGs), however the more deterministic nature of PEGs gives rise to some very important differences. The included grammar analysis finds several typical errors in PEGs, including left recursion.

Design

The PEGTL is designed to be "lean and mean", the core library consists of approximately 6000 lines of code. Emphasis is on simplicity and efficiency, preferring a well-tuned simple approach over complicated optimisations.

The PEGTL is mostly concerned with parsing combinators and grammar rules, and with giving the user of the library (the possibility of) full control over all other aspects of a parsing run. Whether/which actions are taken, and whether/which data structures are created during a parsing run, is entirely up to the user.

Included are some examples for typical situation like unescaping escape sequences in strings, building a generic JSON data structure, and on-the-fly evaluation of arithmetic expressions.

Through the use of template programming and template specialisations it is possible to write a grammar once, and use it in multiple ways with different (semantic) actions in different (or the same) parsing runs.

With the PEG formalism, the separation into lexer and parser stages is usually dropped -- everything is done in a single grammar. The rules are expressed in C++ as template instantiations, and it is the compiler's task to optimise PEGTL grammars.

Status

Each commit is automatically tested with multiple architectures, operating systems, compilers, and versions thereof.

Each commit is checked with GCC's and Clang's sanitizers, Clang's Static Analyzer, and clang-tidy. Additionally, we use CodeQL to scan for (security) issues.

Code coverage is automatically measured and the unit tests cover 100% of the core library code (for releases).

Releases are done in accordance with Semantic Versioning. Incompatible API changes are only allowed to occur between major versions.

Thank You

In appreciation of all contributions here are the people that have directly contributed to the PEGTL and/or its development.

amphaal anand-bala andoma barbieri bjoe bwagner cdiggins clausklein delpinux dkopecek gene-hightower irrequietus jedelbo joelfrederico johelegp jovermann jubnzv kelvinhammond kneth kuzmas lambdafu lichray michael-brade mkrupcale newproggie obiwahn ohanar pauloscustodio pleroux0 quadfault quarticcat ras0219 redmercury robertcampion samhocevar sanssecours sgbeal skyrich62 studoot svenjo wickedmic wravery zhihaoy

The Art of C++

The PEGTL is part of The Art of C++.

colinh d-frey uilianries

License

Open Source Initiative

The PEGTL is certified Open Source software. It may be used for any purpose, including commercial purposes, at absolutely no cost. It is distributed under the terms of the MIT license reproduced here.

Copyright (c) 2007-2021 Dr. Colin Hirsch and Daniel Frey

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].