[antlr-interest] Fail to pass test in C++ Grammar

Nigel Sheridan-Smith nbsherid at secsme.org.au
Mon Jan 10 14:18:16 PST 2005



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Åí´úÒã
> Sent: Tuesday, 11 January 2005 3:28 AM
> To: antlr-interest
> Subject: [antlr-interest] Fail to pass test in C++ Grammar
> 
> Hi, everyone:
> 	I'm new to ANTLR, and I desired to do something about analyzing data
> flow in C++.
> 	I downloaded the C++ project led by David from www.antlr.org's
> grammar section. and compiled in MSVC 7.1, it compiles well. However, I
> can't even pass the simplest test with below contents:
> 
> 	#include <stdio.h>
> 	int main()
> 	{
>  		return 0;
> 	}
> 
> 	I captured the exception and found from where the exception was
> thrown:
> 	//	...
> 	else if ((LA(1) == 0x23 /* '#' */ )
> 					&& (_tokenSet_0.member(LA(2)))) {
> 					mPREPROC_DIRECTIVE(true);
> 					theRetToken=_returnToken;
> 				}
> 	// ...
> 


I think I read somewhere that the C++ grammar does not do pre-processing -
so it will hit trouble on the #include line (and hence, the '#' character it
has trouble with). 

Try removing the #include line, and see if it parses the rest of your simple
program.

Nigel

--
Nigel Sheridan-Smith
PhD research student

Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435



More information about the antlr-interest mailing list