The focus is on simplicity and ease of use, with a direct grammar interpreter. The performance of a pPEG parser  can compete with parser code generato

GitHub - pcanz/pPEG: A portable PEG grammar parser…

submited by
Style Pass
2023-03-14 19:00:03

The focus is on simplicity and ease of use, with a direct grammar interpreter. The performance of a pPEG parser can compete with parser code generators.

The grammar source language is a text string in the host programming language, and the parse tree output is a simple list structure, a subset of JSON.

Here are a couple of examples, the first is in JavaScript, the second is in Python, other programming language have similar implementations. These examples should illustrate how easy it is to specify a grammar and use it to parse an input string and generate a parse tree. The details are not important for the moment, they will be explained shortly.

Notice that the grammar only requires six lines of text to specify a CSV format that is compatible with the RFC 4180 standard.

This grammar compiles directly into a parser, and the resulting parse trees are simple and easy to process, as shown here in JSON format.

Leave a Comment