PEGTL (The Parsing Expression Grammar Template Library) is a C++0x library that allows for creating parsers according to a PEG (Parsing Expression Grammar).
Grammars are embedded as regular C++ code, created with template programming (not template meta programming).
These hierarchies naturally correspond to the inductive definition of PEGs. The library extends on the subject of PEGs with new expression types, actions that can be attached to grammar rules, and mechanisms to ensure helpful diagnostics in case of parsing errors.
PEGs are superficially similar to Context-Free Grammars (CFGs); for a description see Wikipedia page on PEGs or this paper on PEGs by Bryan Ford.
Detailed instructions on how to install and use the PEGTL utility on your Mac are available HERE.
Here are some key features of "PEGTL":
· Comprehensive set of parsing rules.
· Grammars and actions embedded in C++.
· C++ compiler-optimised parsing grammars.
· Some generic actions, like sub-expression capturing.
· Some trivial automatic optimisations, to be extended.
· Diagnostics with readable printing of grammar rules.
· Examples that show how to use the features of the library.
User-defined input abstractions, supplied:
· files via mmap(2),
· strings (and files via strings),
· ranges of forward iterators, and
· input iterators w/automatic minimal buffering.
User-defined debug abstractions, supplied:
· 'full speed, bool result',
· 'less speed, readable error messages',
· 'try full-speed, re-parse w/less-speed on error',
· plus optionally full trace of all invoked rules.
User-defined logging abstractions, supplied:
· simple logging to std::cerr.
What's New in This Release: [ read full changelog ]
· Removed superfluous includes ( issue 5 ).
· Fixed bug in not_at rule regarding wrong propagation of errors ( issue 3 ).