ANTLR JavaScript 目标 [英] ANTLR JavaScript Target

查看:19
本文介绍了ANTLR JavaScript 目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 ANTLR 为带有 Java 目标的标记语言生成解析器 + 树语法,效果很好.现在我试图在 JavaScript 中获取目标以在我的 Web 浏览器中使用它.

但是,我无法找到有关如何执行此操作的任何好的文档.我在 ANTLR IDE 中使用 Eclipse,当我将语言指定为 JavaScript 时,出现以下错误.

此行有多个标记

  • (10):内部错误:组 JavaScript 不满足接口 ANTLRCore:这些模板上的参数不匹配 [treeParser(grammar, name, scopes, tokens, tokenNames, globalAction, rules, numRules, bitsets, labelType, ASTLabelType, superClass, members, filterMode)]

  • (10):内部错误:java.util.NoSuchElementException:没有这样的属性:模板上下文中的filterMode [treeParser]

如果有人能帮我解决这个问题,或者给我指点我可以阅读的有关使用 ANTLR 的 JavaScript 目标的材料,那就太好了.

谢谢

解决方案

将近 3 个月前发布到 GitHub 的 ANTLR4 的新 JS Lang 目标:

antlr/antlr4-javascript

它尚未集成到正式版本中,但您可能只需将其放入最新的 ANTLR4 代码库并自己重新编译 ANTLR.

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

解决方案

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.

这篇关于ANTLR JavaScript 目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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