[antlr-interest] antlrworks bug: invalid code generatedwithsemantic predicates
Putrycz, Erik
Erik.Putrycz at nrc-cnrc.gc.ca
Tue Sep 11 10:37:15 PDT 2007
Ok, I figured out how to write this in a nicer way. My problem is
solved.
However this case looks like a bug around?!
Erik.
________________________________
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Putrycz, Erik
Sent: Tuesday, September 11, 2007 12:15 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] antlrworks bug: invalid code
generatedwithsemantic predicates
My (ugly) rule is the following
comparison
: (simpleComparison multiComparisonOp composed_test) =>
simpleComparison
-> ^(BASIC_COMPARISON simpleComparison)
//basic multiple comparison M1D906RECORD-TYPE = 10 OR 30 OR
70
| (simpleComparison (multiComparisonOp comp_op? arith_expr)+
(multiComparisonOp simpleComparison)?) =>
simpleComparison (boolOp=multiComparisonOp
(compOp=comp_op)? arith_expr)+
-> {compOp != null}? ^(MULTI_COMPARISON simpleComparison
^($boolOp ^($compOp arith_expr))*)
-> ^(MULTI_COMPARISON simpleComparison ^($boolOp
arith_expr)*)
// case with brackets M1D906RECORD-TYPE = (10 OR 30 OR 70)
| (arith_expr comp_op LPAREN arith_expr (multiComparisonOp
comp_op? arith_expr)+ RPAREN) =>
arith_expr comp_op LPAREN arith_expr
(boolOp=multiComparisonOp (compOp=comp_op)? arith_expr)+ RPAREN
-> {compOp != null}? ^(MULTI_COMPARISON arith_expr comp_op
arith_expr ^($boolOp ^($compOp arith_expr))*)
-> ^(MULTI_COMPARISON arith_expr comp_op arith_expr
^($boolOp arith_expr)*)
| simpleComparison
-> ^(BASIC_COMPARISON simpleComparison)
;
The bug happens when I changed (simpleComparison (multiComparisonOp
comp_op? arith_expr)+) => to (simpleComparison (multiComparisonOp
comp_op? arith_expr)+ (multiComparisonOp simpleComparison)?) =>
The invalid code is generated for comp_op? which is a simple rule:
comp_op:
'IS'? 'NOT'?
( (LESS^ | ('LESS'^ 'THAN'!))
| (GREATER^ |('GREATER'^ 'THAN'!))
| (EQUAL^ | ('EQUAL'^ 'TO'?))
| GREATEREQUAL^
| LESSEQUAL^)
;
There is no particular warning generated. I only have "no lexer rule
corresponding to token:..." warnings.
Erik Putrycz, Ph.D - Research Associate / (613) 990 0681
Institute for Information Technology - Software Engineering Group
National Research Council, Canada - Building M-50, 1200 Montreal Road
Ottawa, Ontario, CANADA K1A 0R6
________________________________
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Tuesday, September 11, 2007 11:41 AM
To: antlr Interest
Subject: Re: [antlr-interest] antlrworks bug: invalid code generated
withsemantic predicates
Hi. that's an ANTLR issue if anything. Please narrow it down to a
simple rule that generates invalid code. Were there any errors/warnings
from ANTLR?
Ter
On Sep 11, 2007, at 8:24 AM, Putrycz, Erik wrote:
I'll try to narrow this down but with some semantic predicates,
antlrworks causes this error:
[11:20:50] \tmp\antlrworks\Cobolv3Parser.java:25462: illegal start of
expression
[11:20:50] int alt=;
[11:20:50] ^
[11:20:50] 1 error
Erik Putrycz, Ph.D - Research Associate / erik.putrycz at nrc-cnrc.gc.ca
<mailto:erik.putrycz at nrc-cnrc.gc.ca> / (613) 990 0681
Institute for Information Technology - Software Engineering Group
National Research Council, Canada - Building M-50, 1200 Montreal Road
Ottawa, Ontario, CANADA K1A 0R6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070911/63fe5ac9/attachment.html
More information about the antlr-interest
mailing list