Carl Sorensen wrote:
Almost a year ago, Pedro Kroger was working on a bnf description of
lilypond. (see http://lists.gnu.org/archive/html/lilypond-
devel/2004-10/msg00074.html). Han-Wen suggested hacking Bison so that
it would produce the BNF directly from the .yy file.
I went a different direction, and produced a python script that ignores
all the C++ stuff in parser.yy, resulting in a BNF description of
lilypond that is generated directly from the parser.
I've attached the script (yy2bnf.py), along with the result of running
the script on the current CVS version of parser.yy (lilypond.bnf).
I'd like to suggest that lilypond.bnf be added to the documentation, to
be automatically generated as part of the make process, using yy2bnf.py.
That would be cool, but just dumping a BNF somewhere is a bit
half-baked. Wouldn't it be better to make a "literate Yacc", where we
intersperse explanations of the grammar (in texinfo format, so it can be
integrated with the program reference manual) with the BNF itself? Also,
a couple of nitpicks
* BNF usually uses a slightly different syntax
<nonterminal> ::= <nt1> <nt2>
I believe. But frankly, I don't care about
* The current script doesn't strip /* */ comments.
--
Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen
_______________________________________________
lilypond-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-devel