APG
… an ABNF Parser Generator
|
As mentioned in the introduction, APG begins with the observation that RFC 5234 defines seven different types of phrase-describing or phrase-matching operations which conveniently form a tree suitable for recursive-descent parsing. This is illustrated in figure 1. of the ABNF discussion. The job of the generator is to specialize this general tree to a specific grammar, equipping the resulting nodes with the grammar-specific information needed to carry out it operation. For example, a literal string node would need to be equipped with the specific literal string specified in the grammar. This is illustrated in figure 2. of the ABNF discussion.
RFC 5234 defines the ABNF rules with an ABNF grammar. That is, ABNF for ABNF. Therefore, the APG parser generator is, in fact, an APG parser itself. However, in this case, there is an easy answer to the "chicken or the egg" question. The functions that perform the node operations and the format for the node data come first. The parser that generates the node data comes second. (Although, as any programmer will know, they both need to be debugged simultaneously.) Also, the first time through, a bootstrap generator needs to be hand-written. Later, when everything is working, it is then possible to generate an APG parser to replace the bootstrap making it all self-contained. The parser generator and the parsers it produces both require the same library of parser and operator functions.
APG Version 7.0 comes with both a stand-alone, command-line function for generation the grammar files from which parsers are constructed and an API that can be used to build custom applications for generating grammar files or parsers directly on the fly without the need for intermediate grammar files.
For the command-line function, see the documentation details in config.h and functions referred to therein. To build the application from the ./apg
directory
(For step-by-step instructions using Eclipse for C/C++
see the file Installation.md.)
For the generator API see the The Parser Generator API.
APG version 7.0 also reintroduces the option to generate Partially-Predictive Parsing Tables (PPPT) which have the ability to greatly improve the performance of the generated parsers. See PPPT for a discussion and documentation.