views:

188

answers:

1

The translator could be in boost::spirit too. I couldn't find any in the Internet. Maybe I should make one?

+1  A: 

From the spirit introduction:

Expression templates allow us to approximate the syntax of Extended Backus-Normal Form (EBNF) completely in C++.

So you can almost write plain EBNF, no need for a translator.

I'm not so familiar with spirit to know how exactly the syntax is different, but if the differences of spirit C++ EBNF and real EBNF are minor a simple sed script may suffice.
If not you are right, you could write a spirit parser that understands EBNF and then use the AST to create C++ code that is a spirit representation of that AST.

lothar
For large EBNFs (http://grammatica.percederberg.net/grammar/asn1/asn1.grammar), even thou it's almost identical, it's still a pain. It's not necessary to have one, but it would be helpful.
If your Grammar is that large, you probably don't want to use Spirit for it ;)
Billy ONeal