This package has been available for more than a year on the web.
Only the documentation and comments have been revised since
then. I've hesitated about announcing it -- partly because I'm
awed by Brad Rodriguez' bnf parser:
http://www.zetetics.com/bj/papers/bnfparse.htm
But it is a different approach, which generates Forth source
text definitions for parsing ANS Forth strings, from bnf
productions.
The bnf syntax for productions is no way as elegant as Brad's,
but the correspondence to bnf forms does aim to be fairly
straightforward.
Repetition forms are treated explicitly, with some unrolling
optimization.
The text output is formatted with indentations, and there are
words for outputting comments. The generated output code uses a
control construct called ELSES, inspired by Wil Baden's THENS,
which assumes knowledge of the control stack. It works with pfe
and gforth.
The generator itself is ANS Forth compatible with a few
environmental dependencies described in the comments. It uses
the dynamic strings package with its string stack. That could
no doubt be avoided, but why would you want to? :-)
A description of the bnf template sheme can be found in Sections
2 and 5 here:
http://www-personal.umich.edu/~williams/archive/forth/strings/expr.html
The generator includes an uncommentable example at the end.
Links for the generator, its example output, and another
example, in fact the whole shebang, are here:
http://www-personal.umich.edu/~williams/archive/forth/strings/index.html#parsegen
-- David


|