[antlr-interest] function call and expressions in C++ grammar

Tarun Khanna tarunkhanna at gmail.com
Tue Jul 26 08:49:25 PDT 2005


I am trying to parse C++ expressions. From the grammar on the ANTLR website 
I can see this rule (simplified here, I removed the other alternatives)

postfix_expression
{TypeSpecifier ts;
DeclSpecifier ds = dsInvalid; // Purpose ?
}
:
primary_expression
(options {warnWhenFollowAmbig = false;}:
LSQUARE expression RSQUARE
| LPAREN (expression_list)? RPAREN 
| DOT id_expression
| POINTERTO id_expression
| PLUSPLUS 
| MINUSMINUS
)*
) ;

Although it would parse a C++ expression just fine, I don't know how would 
it differentiate between the following. I want to create different root 
nodes in the following two situations. However with the above grammar I 
can't find a way to do so.

a(a, b) and
(a, b)

-- 
Tarun Khanna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050726/a5565657/attachment.html


More information about the antlr-interest mailing list