[antlr-interest] Problem with Cpp-Grammer (declarator)

fwittenburg at nemetschek.de fwittenburg at nemetschek.de
Thu Oct 20 05:48:44 PDT 2005


Hello,

I have code, that looks like this:

int (data[6]); // unexpected token: ;
void datafun(char *(installsources[6])); // expecting STAR, found
'installsources

I have tried to fix the parser, with

direct_declarator
{char *id;
CPPParser::TypeQualifier tq;}
...
| LPAREN declarator RPAREN // declarator_suffixes
;

But now, the parser can't handle

typedef int (__cdecl * _onexit_t)(void);

Since I'm not really an expert, I would like to ask for a fix.

Another little bug is: reinterpret_cast<const char*>(data)

I fixed it with:
postfix_expression
...
("dynamic_cast"|"static_cast"|"reinterpret_cast"|"const_cast") // Note
const_cast in elsewhere
LESSTHAN ("const")? ts = type_specifier[ds] (ptr_operator)? GREATERTHAN
LPAREN expression RPAREN

Is there a better way to do it?

Regards Florian




**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper and SOPHOS Antivirus for the presence of computer viruses.

**********************************************************************



More information about the antlr-interest mailing list