APG - smartnuf/ees GitHub Wiki
(S)ABNF Parser Generator (APG)
I thought this might be a good place to study recursive decent parsers with backtracking. So I read the overview, and cloned the source https://github.com/ldthomas/apg-6.3. I built and installed this (on cygwin) -- with some minor modifications to coax it pass by C++11 compiler, and looked for the sources generated of the examples, I couldn't find any?!
However, issuing apg --help
yields (among other options)
/in:pathname - pathname of input SABNF grammar (required)
/out:path - path for generated parser, including trailing delimiter (default = ./ or current working directory)
/C:name - C-language parser project name (outputs files name.h & name.c)
/C++:name - C++ language parser project name (outputs files name.h & name.cpp)
There is an SABNF (I presume) file at apg-6.3/demo/Setup.bnf
So, from the sibling tmp
directory I issued apg /in:../apg-6.3/demo/Setup.bnf
, and got (amongst other stuff) <no parser output requested>
. So I issued apg /in:../apg-6.3/demo/Setup.bnf
, and was rewarded with
*** C parser generated
tmp.h
tmp.c
However, tmp.h
simply #define
s some constants, and tmp.c
defines an array of unsigned long constants:
static unsigned long int ulData[1604] = {
1, 2, 12832, 9, 127, 1234, 20, 4, ....
This wasn't the human readable source I was looking for...
Also seems to be buggy See
Other options to inspect,
- Yapps, which says it is LL(1), so I'll move on to the
- human readable parser. See [HPG]