tunnelvisionlabs / antlrworks2

Tunnel Vision Labs' ANTLRWorks 2 IDE
http://tunnelvisionlabs.com/products/antlrworks
Other
48 stars 21 forks source link

Cannot use named channels #34

Closed fraschfn closed 10 years ago

fraschfn commented 10 years ago

When using named channels the IDE issues warning 155 (unrecognized constant value) although the constant is defined. This prevents the associated parser to run the testrig. The parser/lexer works fine when using VS (I drop the "final" for C#).

lexer grammar NamedChannelsLexer;

@members
{
        public static final int COMMENT_CHANNEL = 3;
}

Abc : 'ABC';

AnyThingElse : . -> channel(COMMENT_CHANNEL); 
sharwell commented 10 years ago

Warning 155 is correct in this case. Your -> channel command references a constant which is declared in a target-language-specific syntax that ANTLR cannot understand. When using the lexer interpreter (either directly, or indirectly through something like the ANTLRWorks 2 lexer debugger), lexer commands which report this warning will not be executed.

We cannot reproduce the other issue in the current form. Please provide a complete example of the problem along with the version of ANTLR you are using, and reopen the issue.

fraschfn commented 10 years ago

I assume predicates are ignored as well.

Does the testrig also use the interpreter?

Btw. I'm using version 2.2.2.

sharwell commented 10 years ago

The Run in TestRig command does not use the interpreter. It uses the Java target to compile the lexer and parser, and then runs the TestRig command on the result.