Hints regarding the use of ANTLR v3 generated files in Flash Builder 4.5.1
Asked Answered
H

1

2

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.

Hunks answered 22/6, 2011 at 22:45 Comment(0)
H
1

Terence Parr, the project lead of ANTLR just confirmed, that ANTLRworks needs a new compile. Thanks for great support!

Hunks answered 22/6, 2011 at 23:37 Comment(2)
I tried to compile the *.g file using antlr-3.3-complete.jar. Since the output doesn't compile too, the problem seems to be in fact inside of the base ANTLR system, not ANTLRworks. I'll file a bug report.Hunks
Last comment: All in all, the generated AS code doesn't seem to match the above mentioned ANTLR runtime library. Found more problem. The runtime defines a getter line() of ChartStream, the generated AS code calls it wrong, etc. Hm...Hunks

© 2022 - 2024 — McMap. All rights reserved.