有没有为ANTLR工作的C ++语法文件? [英] Is there a working C++ grammar file for ANTLR?

查看:168
本文介绍了有没有为ANTLR工作的C ++语法文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ANTLR是否有任何现有的C ++语法文件?

Are there any existing C++ grammar files for ANTLR?

我正在寻找lex,而不是解析一些C ++源代码文件。

I'm looking to lex, not parse some C++ source code files.

我查看了 ANTLR语法页面看起来像Sun Microsystems创建的列表此处

I've looked on the ANTLR grammar page and it looks like there is one listed created by Sun Microsystems here.

但是,它似乎是一个生成的Parser。

However, it seems to be a generated Parser.

任何人都可以指向一个C + + ANTLR词法语法文件?

Can anyone point me to a C++ ANTLR lexer or grammar file?

推荐答案

C ++语法分析程序难以建立。

C++ parsers are tough to build.

我不能说出使用 ANTLR的C ++语法的经验。 在这里我讨论我通过阅读我在ANTLR网站上看到的附注中的笔记所学到的;在本质上,作者产生了一种不完整的语法。这只是为了C ++ 98。自从我看起来已经有一段时间了;可能还有其他人。

I can't speak with experience about using ANTLR's C++ grammars. Here I discuss what I learned by reading the notes attached to the the one I did see at the ANTLR site; in essence, the author produced an incomplete grammar. And that was for just C++98. It has been awhile since I looked; there may be others.

我们的 DMS Software Reengineering Toolkit 有一个强大的C ++前端

lexer处理ANSI,GCC3,MS Visual Studio 2008的所有标准,包括大精度浮点数等。

The lexer handles all the cruft for ANSI, GCC3, MS Visual Studio 2008, including large-precision floating point numbers, etc.

拥有just解析器实际上并不是非常有用。除了只是解析,我们的前端将构建AST,构建准确的符号表(对于C ++,这是极难做到的),执行函数本地流分析,并允许您执行程序转换等。 解析后的生活

Having "just" a parser is actually not very useful. Above and beyond "just parsing", our front end will build ASTs, build accurate symbol tables (for C++, this is extremely hard to do), perform function-local flow analysis, and allow you to carry out program transformations, etc. See Life After Parsing.

这篇关于有没有为ANTLR工作的C ++语法文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆