Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
翻译器也可以在 boost::spirit 中。我在互联网上找不到任何东西。也许我应该做一个?
从精神介绍:
表达式模板允许我们在 C++ 中完全近似扩展巴科斯范式 (EBNF) 的语法。
所以你几乎可以编写简单的 EBNF,不需要翻译器。
我对spirit不太熟悉,不知道语法到底有什么不同,但是如果spirit C++ EBNF和真正的EBNF的差异很小,一个简单的sed脚本就足够了。 如果不是这样,您可以编写一个理解 EBNF 的精神解析器,然后使用 AST 创建作为该 AST 精神表示的 C++ 代码。