有关在 Flash Builder 4.5.1 中使用 ANTLR v3 生成的文件的提示
根据这些 说明,我尝试使用 ANTLR 生成的 *.as 文件在当前的 Flash Builder 4.5.1 项目中。
因此,我将这个 ANTLR 的 Actionscript 运行时 添加到我的项目中 - 没有出现任何问题。
我使用 ANTLRWorks 编译了词法分析器/解析器规范,也没有出现任何问题。
我在源 *.g 文件中添加了语言选项,以使 ANTLR 生成 Actionscript 源:
options {
backtrack = true;
memoize = true;
k=2;
output = AST;
language=ActionScript; // Added this
ASTLabelType = CommonTree;
}
不幸的是,ANTLR/ANTLRworks 生成的 Actionscript 代码有问题:
Catch 语句读起来像这样 catch (RecognitionException re)
,但是应如下所示:catch (re:RecognitionException)
。
此外,Flash Builder 在这里抱怨数组的使用:
public override function get tokenNames():Array { return PhpParser.tokenNames; }
任何人都可以确认这些问题并可能提供如何解决它们的提示吗?
UPDATE-1
快速查看 ANTLR v3.3 的源代码可以发现此模板代码 [第 142 行 @ ActionScript.stg]:
catch ( re:RecognitionException )
因此,当前的 3.3 分支似乎知道正确的语法。
不幸的是,当前的 ANTLRworks 1.4.2(包括 3.3 分支)失败了。
According to these instructions, I'm trying to use ANTLR generated *.as files in a current Flash Builder 4.5.1 project.
Therefore, I added this ANTLR's Actionscript runtime to my project - without problems.
I compiled lexer/parser specs using ANTLRWorks without problems too.
I added the language option to the source *.g file to make ANTLR generate Actionscript sources:
options {
backtrack = true;
memoize = true;
k=2;
output = AST;
language=ActionScript; // Added this
ASTLabelType = CommonTree;
}
Unfortunately, the ANTLR/ANTLRworks generated Actionscript code is buggy:
Catch statements read like this catch (RecognitionException re)
, but should read like this: catch ( re:RecognitionException )
.
Furthermore, Flash Builder complains about the use of Array here:
public override function get tokenNames():Array { return PhpParser.tokenNames; }
Could anybody confirm these problems and probably provide hints how to solve them?
UPDATE-1
A quick look at the sources of ANTLR v3.3 revealed this template code [line 142 @ ActionScript.stg]:
catch ( re:RecognitionException )
Thus, the current 3.3 branch seems to know the correct syntax.
Unfortunately, the current ANTLRworks 1.4.2 - which includes the 3.3 branch - fails.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ANTLR 项目负责人 Terence Parr 刚刚证实,ANTLRworks 需要新的编译。感谢您的大力支持!
Terence Parr, the project lead of ANTLR just confirmed, that ANTLRworks needs a new compile. Thanks for great support!