[antlr-interest] antlr: beginner question...
pady
prabha_pady at comcast.net
Mon Dec 22 11:42:36 PST 2008
Started using antlr this weekend...so please bear my lack of understanding
( i did buy terence's book and am on page 70... )...
I wrote my first grammar...cut & paste from terence's java grammar...a
subset just to handle if-else statements...
When I generate java from this ( using antlrworks also ), I get the
following warnings which I dont understand - can somebody explain...
[14:29:59] warning(200): gwf.g:10:34: Decision can match input such as
"'else'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
[14:30:00] warning(200): C:\projects\antlr\gwf\gwf.g:10:34: Decision can
match input such as "'else'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
what are the alternatives ? i cannot figure out how someone can get to
'else' without going through just the 2nd alternative of "statement" rule
below ? I have also attached the complete grammar ( not sure if this mailing
list allows attachments... )
Grammar:
prog
: statement+
;
statement
: statementExpression ';'
| 'if' boolExpression statement (options {k=1;}:'else' statement)?
| '{' statement* '}'
;
boolExpression
: '(' expression ')'
;
statementExpression
: function '(' expressionList ')'
| Identifier('.' Identifier)* assignmentOperator expression
;
function
: 'sendEmail'
| 'loadData'
| 'loadAllUsers'
| 'loadUsersFromRole'
;
expressionList
: expression (',' expression)*
;
...
...
Thx
-- pady
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gwf.g
Type: application/octet-stream
Size: 4150 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081222/d233e32d/attachment.obj
More information about the antlr-interest
mailing list