views:

145

answers:

2

I am looking for a dynamic C-based parser/framework. It must be dynamic because the EBNF is constantly changing, something like bison is not applicable in this situation. And boost::spirit is practically useless to me because it requires C++.

Does anyone have an idea?

A: 

You don't have many choices either you write your own recursive descent parser or use a generator like bison or the older lex/yacc. If BNF changes you will be lucky to be able to regenerate.

stacker
You can certainly use ANTLR to generate a recursive descent parser; it is not clear whether the changing EBNF will be a problem.
Jonathan Leffler
Classic parser generators require what amounts to static grammars, (unless you are willing to spawn a process to run the parser generator, which the OP didn't appear to want to do)
Ira Baxter
A: 

If you want the grammar to change while the computation is running, then what you want is an Earley-style context free parser. You can change the rules at any time and run the Earley parsing algorithm.

If the grammar changes "slowly" (e.g., once a day), then you don't need a dynamically-augmentable parser like Earley; you can use conventional parser generators and simply run them as needed.

Ira Baxter
Sorry for assuming that the BNF changes after review by professor, at least I learned that I'm not up to date wth this.
stacker
That could be the way to go.I will certainly explore this algorithm. Thank you!
Flaps