[antlr-interest] failed optimisation

Anthony Youngman Anthony.Youngman at ECA-International.com
Tue Jun 1 07:25:25 PDT 2004


I've just tried to optimise the following lexer rule. You can see my
original code, which works fine, and my attempted optimisation (using
STRING_TEXT) which failed. If I'm using "greedy = false", do I need
something at the end of STRING_TEXT for it to match? or if not, how do I
get it to do what I want (more for legibility than anything else).

And, similarly but not quite the same, is there any way I can recognise
a terminator without eating it? Eg "newline" will terminate a comment,
but I need to leave it alone to generate an nl token - eating it as part
of the comment will corrupt the lex.

Cheers,
Wol


// note the '\\' syntax for a single backslash and '\'' for single quote
...
STRING_LITERAL
//	: '"' (~('"'))* '"'
//	: '"' STRING_TEXT '"'
	: '"' (options {greedy=false;} : .)* '"'
	| '\'' (~('\''))* '\''
	| '\\' (~('\\'))* '\\'
	;

//protected STRING_TEXT options {greedy=false;} : (.)* ;


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

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

<*> 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