ColdFusion 代码解析器?
我正在尝试创建一个应用程序来搜索我公司的 ColdFusion 代码库。 我希望能够进行智能搜索,例如:查找定义函数的位置(而不是在调用该函数的所有地方进行搜索)。 为了做到这一点,我需要解析 ColdFusion 代码来识别函数声明、函数调用、数据库查询等内容。
我已经研究过使用 lex 和 yacc,但我以前从未使用过它们,而且学习曲线似乎非常陡峭。 我希望已经有一些我可以使用的东西。 我的另一个选择是一堆难以维护的正则表达式意大利面条代码,我想避免这种情况。
I'm trying to create an app to search my company's ColdFusion codebase. I'd like to be able to do intelligent searches, for example: find where a function is defined (and not hit everywhere the function is called). In order to do this, I'd need to parse the ColdFusion code to identify things like function declarations, function calls, database queries, etc.
I've looked into using lex and yacc, but I've never used them before and the learning curve seems very steep. I'm hoping there is something already out there that I could use. My other option is a mess of difficult-to-maintain regex-spaghetti code, which I want to avoid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用了 CFEclipse 源,因为它是开源的并且有一个解析器。 不确定我们出售/重新分发它的合法性,但我们仅将其用作内部工具。
I used the source to CFEclipse, since it is open source and has a parser. Not sure about the legality of this if we were selling/redistributing it, but we're only using it for an internal tool.
为真实语言编写解析器通常很困难,因为它们包含 Lex 和 Yacc 通常不能很好处理的结构,例如,语言不是 LALR(1)。 ColdFusion 可能比某些方法更容易,因为它具有类似 XML 的风格。
如果您想快速构建一个复杂的解析器,您可以考虑使用我们的
DMS 软件重新工程工具包,具有 GLR 解析支持。
如果您想避免编写自己的正则表达式或破解所有这些正则表达式,您可以考虑我们的源代码搜索引擎。 它具有语言敏感的解析器,可以非常快速地搜索非常大的源代码库。 它的“语言敏感”解析器之一是 AdhocText,它旨在处理“通用”编程语言,例如您可能在随机编程书中找到的语言; 它甚至可以理解像 ColdFusion 这样的类似 XML 的标签。 您可以从提供的链接下载评估版本来尝试。
编辑 4/3/2010:SCSE 最近添加的一项功能是能够分别标记定义和使用。 这将满足OP希望找到函数定义而不是所有调用的愿望。
Writing parsers for real langauges is usually difficult because they contain constructs that Lex and Yacc often don't handle well, e.g., the langauge isn't LALR(1). ColdFusion might be easier than some because of its XML-like style.
If you want to build a sophisticated parser quickly, you might consider using our
DMS Software Reengineering Toolkit which has GLR parsing support.
If you want to avoid writing your own or hacking all those Regexps, you could consider our Source Code Search Engine. It has language-sensitive parsers and can search across very large source code bases very quickly. One of its "language sensitive" parsers is AdhocText, which is designed to handle "generic" programming languages such as those you might find in a random programming book; it even understands XML-like tags such as ColdFusion has. You can download a evaluation version from the link provided to try it.
EDIT 4/3/2010: A recent feature added to the SCSE is the ability to tag definitions and uses separately. That would address the OP's desire to find the function definition rather than all the calls.
没有一个存在。 由于 ColdFusion 更像是脚本而不是代码,我想为它编写解析器会很困难。
ColdFusion Builder 可以在 Eclipse 中将 CFM/CFC 解析为大纲。 也许你可以研究一下 CF Builder 插件是否可以做你想做的事情。
None existed. Since ColdFusion is more like scripts than code, I'd imagine it'll be hard to write a parser for it.
ColdFusion Builder can parse CFM/CFC to an outline in Eclipse. Maybe you can do some research on whether a CF Builder plugin can do what you want to do.