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.

SteAp
  • 11,853
  • 10
  • 53
  • 88

1 Answers1

1

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

SteAp
  • 11,853
  • 10
  • 53
  • 88
  • 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. – SteAp Jun 23 '11 at 20:18
  • 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... – SteAp Jun 23 '11 at 20:39