[antlr-interest] Java doesn't find class definition

Terence Parr parrt at cs.usfca.edu
Thu Apr 12 12:02:09 PDT 2007


On Apr 4, 2007, at 6:27 AM, Johannes Luber wrote:
> Regarding the ANTLR bugs mentioned above: The generated file creates
> three errors. I've used the most recent build of March 30th for  
> ANTLR to
> generate the file.
>
> The rule
>
> NEW_LINE
> 	:	'\u000D' // Carriage return character
> 	|	'\u000A' // Line feed character
> 	|	'\u000D\u000A' // Carriage return character followed by line feed
> character
> 	|	'\u0085' // Next line character
> 	|	'\u2028' // Line separator character
> 	|	'\u2029' // Paragraph separator character
> 	;

Generated code won't work as \u000D is translated early (before  
compilation) by java compiler:

String s = "\u000D\u000A";

won't compile for example.  It sees a newline in a string literal.

This is a Java "issue" really.  I think you'll have to use \r and \n.

> The last error is for the rule
>
> SIMPLE_ESCAPE_SEQUENCE
> 	:	'\\\''
> 	|	'\\\"'
> 	|	'\\\\'
> 	|	'\\0'
> 	|	'\\a'
> 	|	'\\b'
> 	|	'\\f'
> 	|	'\\n'
> 	|	'\\r'
> 	|	'\\t'
> 	|	'\\v'
> 	;

Weird

SIMPLE_ESCAPE_SEQUENCE
         :       '\"'
         ;

generates:

match('\"');

but

SIMPLE_ESCAPE_SEQUENCE
         :       '\\\"'
         ;

gens

match("\\\\"");

Added to list.

http://www.antlr.org:8888/browse/ANTLR-105

Ter


More information about the antlr-interest mailing list