ANTLR JavaScript 目标
我一直在使用 ANTLR 为带有 Java 目标的标记语言生成解析器 + 树语法,效果很好。现在我正在尝试获取 JavaScript 中的目标以在我的网络浏览器中使用它。
但是,我无法找到任何关于如何执行此操作的良好文档。我将 Eclipse 与 ANTLR IDE 一起使用,当我将语言指定为 JavaScript 时,出现以下错误。
此行有多个标记
(10):内部错误:组 JavaScript 不满足接口 ANTLRCore:这些模板上的参数不匹配 [treeParser(grammar、name、scopes、tokens、tokenNames、globalAction、rules、numRules、bitsets、labelType) ,ASTLabelType,superClass,成员,filterMode)]
(10):内部错误:java.util.NoSuchElementException:没有这样的属性:模板上下文中的filterMode [treeParser]
如果有人可以帮助我解决这个问题或向我指出一些我可以使用 ANTLR 阅读有关 JavaScript 目标的材料,那就太好了。
谢谢
I have been using ANTLR to generate a parser + tree grammar for a mark up language with Java target which works fine. Now I am trying to get the target in JavaScript to use it in my web browser.
However, I have not been able to locate any good documentation on how to go about doing this. I am using eclipse with ANTLR IDE, and when i specify the language as JavaScript, I get the following errors.
Multiple markers at this line
(10): internal error: group JavaScript does not satisfy interface ANTLRCore: mismatched arguments on these templates [treeParser(grammar, name, scopes, tokens, tokenNames, globalAction, rules, numRules, bitsets, labelType, ASTLabelType, superClass, members, filterMode)]
(10): internal error: java.util.NoSuchElementException: no such attribute: filterMode in template context [treeParser]
If anyone could help me out with this or point me to some material which I could read about the JavaScript target with ANTLR, it would be great.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
ANTLR4 有一个新的 JS Lang 目标,大约 3 个月前发布到 GitHub:
antlr/antlr4-javascript
它尚未集成到正式版本中,但您可以将其放入最新的 ANTLR4 代码库中并自行重新编译 ANTLR。
There is a new JS Lang target for ANTLR4 that was posted to GitHub almost 3 months ago:
antlr/antlr4-javascript
It's not integrated into an official release yet, but you can probably just throw it into the latest ANTLR4 codebase and recompile ANTLR yourself.
您应该使用最新版本 (3.3),在以前的版本中,javascript 目标未正确集成。仍然存在一些错误,但您可以看到一个工作示例,其中包含一些指导和链接
http://blog.barvinograd.com/ 2011/03/online-function-grapher-formula-parser-part-2/
You should use the latest version (3.3), in previous versions the javascript target was not properly integrated. There still some bugs, but you can see a working example with some guidance and links on
http://blog.barvinograd.com/2011/03/online-function-grapher-formula-parser-part-2/
看来 JavaScript 目标在 3.4 发行版中再次被破坏。 3.3 对我来说工作得很好。
It appears as though the JavaScript target is broken again in the 3.4 distribution. 3.3 is working fine for me though.
我一直在努力让它工作,并且在阅读完本文后才成功生成 .js 文件:
http://www.antlr3.org/pipermail/antlr-interest/2011-August/042417.html
来自帖子:
以下是如何开始使用 ANTLR 和 JavaScript后端:
http://antlr.org/download/antlrworks-1.2.2.jar >。 JavaScript 目标
仅当 IDE 生成词法分析器和解析器代码时才起作用(请参阅<
http://antlr.1301665.n2.nabble .com/maven-plugin-and-javascript-target-td3647109.html>)。
如果您尝试从命令行运行 ANTLR v3.1,您将看到错误
消息“错误(10):内部错误:组 JavaScript 不满足
接口 ANTLRCore”。
http://antlr.org/download/antlr-javascript-runtime-3.1.zip
注意,如果生成过程中出现错误,那么由于某种原因
“生成代码”操作不再有效。只需关闭语法并
从“打开最近的”菜单重新打开它。
I have been trying to get this working, and have only just managed to generate .js files succesfully after reading this:
http://www.antlr3.org/pipermail/antlr-interest/2011-August/042417.html
From the post:
Here's how to get started with ANTLR and the JavaScript back-end:
http://antlr.org/download/antlrworks-1.2.2.jar>. The JavaScript target
only works when the IDE generates the lexer and parser code (see <
http://antlr.1301665.n2.nabble.com/maven-plugin-and-javascript-target-td3647109.html>).
If you try to run ANTLR v3.1 from the command line, you will see the error
message "error(10): internal error: group JavaScript does not satisfy
interface ANTLRCore".
http://antlr.org/download/antlr-javascript-runtime-3.1.zip
Note that if an error occurs in the generation process, then for some reason
the "Generate Code" action no longer works. Simply close the grammar and
re-open it from the "Open Recent" menu.