[antlr-interest] Avoiding warnings without code bloat

Jim Idle jimi at temporal-wave.com
Tue Jun 26 10:42:57 PDT 2007


No, but  you can do this:
fragment
STRING_GUTS :	( EscapeSequence | ~('\\'|'"') )* ;

INC:
	    'include' (' ' | '\t')+ '"' file = STRING_GUTS '"' (' ' |
'\t')* '\r'? '\n'
		{
		    pANTLR3_STRING	    fName;
		    pANTLR3_INPUT_STREAM    in;

		    // Create an intial string, then take a substring
		    // We can do this by messing with the start and end
		    // pointers of tokens and so on. This shows a
reasonable way to
		    // manipulate strings.
		    //
		    fName = $file.text;
		    printf("Including file '\%s'\n", fName->chars);
       	}
;

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Gavin Lambert
> Sent: Tuesday, June 26, 2007 1:30 AM
> To: David Piepgrass; antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Avoiding warnings without code bloat
> 
> At 11:33 26/06/2007, David Piepgrass wrote:
>  >// Strings
>  >SQ_STRING: '\''! ({true}? ESC_SEQ | ~'\'')* '\''!;
>  >DQ_STRING: '"'!  ({true}? ESC_SEQ | ~'"')* '"'!;
>  >BQ_STRING: '`'!  ({true}? ESC_SEQ | ~'`')* '`'!;
> 
> Does ! work in v3 lexers now?  (Maybe I need to pay closer
> attention.)



More information about the antlr-interest mailing list