[antlr-interest] C++ doesn't like my tokens ...

Noel F Bryson nfb at silistix.com
Mon Jul 5 07:43:03 PDT 2004


NULL isn't actually a keyword in C++. It's a macro defined in one of the
header files, for convenience. You could put a #undef NULL in the ANTLR
header section ....

On Mon, 2004-07-05 at 15:29, Anthony Youngman wrote:
> Hi Ric,
> 
> Not sure how to deal with this ... I've got the following tokens in my
> lexer:
> 
> tokens {
> // statements
> 	CALL="CALL";
> 	CALLING="CALLING";
> 	DEFFUN="DEFFUN";
> 	ELSE="ELSE";
> 	END="END";
> 	EXIT="EXIT";
> 	FUNCTION="FUNCTION";
> 	GOTO="GOTO";
> 	IF="IF";
> 	INPUT="INPUT";
> 	LOOP="LOOP";
> 	NULL="NULL";
> 	PRINT="PRINT";
> 	PROGRAM="PROGRAM";
> 	REPEAT="REPEAT";
> 	RETURN="RETURN";
> 	SUBROUTINE="SUBROUTINE";
> 	THEN="THEN";
> 	UNTIL="UNTIL";
> 	WHILE="WHILE";
> // operators
> 	LOGIC_EQ="EQ";
> // descriptors
> 	COMMENT;
> 	LABEL;
> 	MATFUNC;
> // functions
> }
> 
> Which gives me a TokenTypes.hpp as attached. Note the line "NULL = 15,"
> - this causes g++ to blow up pretty badly.
> 
> Obviously my keyword is being treated as a C++ keyword. I would guess,
> as a temporary measure I can manually mangle the keyword, but are there
> any other keywords that are likely to blow up? And if so, how do we
> handle it? Should Antlr do a little mangling of all keywords for
> safety's sake?
> 
> Cheers,
> Wol
> 
>  <<BASICTokenTypes.hpp>> 
> 
> 
> ****************************************************************************
> 
> This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.
> 
> Telephone numbers for ECA International offices are: Sydney +61 (0)2 8272 5300, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.
> 
> ****************************************************************************
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list