[antlr-interest] [BUG FIX] Generates bad empty lookahead test
expression in C++
mzukowski at yci.com
mzukowski at yci.com
Mon Sep 23 09:55:32 PDT 2002
This is fixed in the 2.7.2 alpha code which you can download from
www.antlr.org
Monty
> -----Original Message-----
> From: ods94538 [mailto:ods94538 at yahoo.com]
> Sent: Monday, September 23, 2002 9:49 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] [BUG FIX] Generates bad empty lookahead test
> expression in C++
>
>
> Greetings,
>
> Found the following bug but am unsure how to submit it. Here's the
> skinny; if anyone knows a better place for me to send such stuff,
> please let me know!
>
> The problem occurs with the following (stripped-down) grammar:
>
> -- begin test.g --
>
> options {
> language="Cpp";
> }
>
> class TestLexer extends Lexer;
>
> options {
> k=2;
> charVocabulary='\3'..'\377';
> }
>
> COMMENT
> : "/*"
> ( '*' ~'/'
> | NEWLINE
> | ~('*'|'/'|'\n'|'\r') )*
> "*/"
> ;
>
> NEWLINE: '\r' ('\n')? | '\n' { newline(); };
>
> -- end test.g --
>
> There is a nondeterminism in NEWLINE which generates the following
> lookahead tests in the corresponding lexer method, mNEWLINE. The
> problem is that the "if (true)" is missing parentheses, so the file
> doesn't compile.
>
> -- begin TestLexer.cpp:134-149 --
>
> case static_cast<unsigned char>('\r'):
> {
> match(static_cast<unsigned char>('\r'));
> {
> if ((LA(1)==static_cast<unsigned char>('\n'))
> && (true)) {
> match(static_cast<unsigned char>('\n'));
> }
> else if true { // <-- should be (true)
> }
> else {
> throw ...
> }
> }
> break;
> }
>
> -- end TestLexer.cpp --
>
> I propose the following patch:
>
> CppCodeGenerator.java:3584
> < return "true";
> > return "(true)";
>
> as this seems to generate the correct C++ code.
>
> -- Owen
>
>
>
>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list