質問

I just started looking into ANTLR, and noticed ANTLRWorks 1.5 generates the Java parser file, but with incomplete throws declaration.

Grammar file:

grammar ASTDemo;

options { 
  output=AST; 
}

parse
    :   orexpr+
    |   andexpr+
    |   TAG ' ' parens
    |   TAG (parens andexpr)+
    |   together+
    ;

parens
    :   '(' TAG ')';

andexpr
    :   TAG (AND^ TAG)+;    

orexpr
    :   '[' TAG (OR^ TAG)+ ']';

together
    :   TAG (' '^ TAG)*
    ;

TAG     : ('FOO' | 'BAR');
OR  :   '|';
AND :   ': ';
WS  :   (' ')+;

Here is the sample line that has the incomplete throws statement

public final ASTDemoParser.parse_return parse() throws  {

The current version of JDK being used to launch ANTLRWorks is 1.6x Has anyone seen this before?

The unfortunate part, with this compile error ANTLRWorks is not allowing me to Debug my grammar within it. I'm forced to manually fix the file each time I want to test.

役に立ちましたか?

解決

I have just compiled your grammar using ANTLRWorks 1.5 rc1 and JDK 1.7.0.11.

All compiled well, and mentioned code line looks like:

public final ASTDemoParser.parse_return parse() throws RecognitionException {

It could be arbitrary bug manifestation. Try to recompile it again, and may be you have try to use JDK 1.7.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top