We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
自您提出问题以来一周,回复为零。
如果您找到一个可以解析和转换 ObjectiveC 代码的 ObjectiveC 工具,我会感到惊讶。一般来说,这样的工具确实很难构建,而且有
ObjectiveC 中没有明显的需求。
Clang 似乎是处理 AST 的一个选项,但它显然不是用 ObjectiveC 编码的。我没有任何直接经验,但我知道 Clang 会解析 ObjectiveC 并构建 AST。我想你可以修改 AST,但我不知道你是否可以从中重新生成 ObjectiveC 代码;我听说您可以从 Clang AST 为解析的 C++ 程序生成 C++ 代码。 (Clang 是一个非常难以构建的工具;看看它悠久的历史)。
如果 Clang 不行,您可以考虑我们的 DMS 软件重新工程工具包。 DMS,给定明确的语言描述,将解析、为该语言构建 AST,让您按程序检查/修改 AST,和/或应用
使用指定语言的表面语法编写的源到源转换(在您的情况下,ObjectiveC),并重新生成该语言的有效源代码,包括解析期间收集的注释。
DMS 有多种语言描述,包括 C、Java、C++(包括 C++11)、 COBOL、PHP 等。目前还没有 ObjectiveC 的描述,但 DMS 旨在使提供这种语言描述变得容易,从我们已经拥有的语言描述中可能显而易见。与构建解析/转换/漂亮打印机制(构建起来真的非常困难!)相比,定义语言前端是一项相当小的任务。
2012 年 6 月 8 日编辑:(提问后 9 个月,没有其他回复)
DMS 现在有一个 ObjectiveC 前端。您可以在此处查看 DMS 为小型 ObjectiveC 代码生成的解析树: https://stackoverflow.com/a/10749970/120163< /a> 是的,DMS 可以从此类(修改后的)树中重新生成有效的 ObjectiveC 源代码。
A week since your question, and zero responses.
I'd be surprised if you found an ObjectiveC tool that let you parse and transform ObjectiveC code. Such tools are really hard to build in general, and there's
no obvious demand for one in ObjectiveC.
Clang seems like an option for processing ASTs, but it obviously isn't coded in ObjectiveC. I don't have any direct experience, but I understand Clang will parse ObjectiveC and build an AST. I suppose you can modify the AST, but I don't know if you can regenerate ObjectiveC code from that; I hear you can generate C++ code from a Clang AST for a parsed C++ program. (Clang is a tool that was really hard to build; look at its long history).
If Clang won't do, you might consider our DMS Software Reengineering Toolkit. DMS, given an explicit language description will parse, build ASTs for that language, let you inspect/modify the AST procedurally, and/or apply
source-to-source transformations written using the surface syntax of the specified language (in your case, ObjectiveC), and regenerate valid source code in the language, including comments collected during parsing.
DMS has many language descriptions, including C, Java, C++ (including C++11), COBOL, PHP, etc. There isn't presently a description for ObjectiveC, but DMS is designed to make it easy to provide such language description as might be obvious from what we already have. Compared to building the parsing/transformation/prettyprinting machinery (which was all really hard to build!), defining a language front end is a pretty small task.
EDIT June 8, 2012: (9 months after question, no other responses)
DMS now has an ObjectiveC front end. You can see a DMS-generated parse tree for a small ObjectiveC code here: https://stackoverflow.com/a/10749970/120163 Yes, DMS can regenerate valid ObjectiveC source code from such (modified) trees.
这可能会有所帮助...
http://code.google.com/p/objectiveclipse/source/browse/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/?r =981ddadee087d6bb6a27260c019df97e6e40f373#parser%2Fast%2Fcomplete
This might be helpful...
http://code.google.com/p/objectiveclipse/source/browse/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/?r=981ddadee087d6bb6a27260c019df97e6e40f373#parser%2Fast%2Fcomplete