[antlr-interest] how to implement this string rule?

Indhu Bharathi indhu.b at s7software.com
Thu Jun 4 09:55:46 PDT 2009


STRING
: '"' ( options {greedy=false;} : . )* '"'
;

Greedy is turned off so that .* doesn't consume the terminating '"' also.

Cheers, Indhu

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Xiaohua Guo
Sent: Thursday, June 04, 2009 10:15 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] how to implement this string rule?

Hi, 
I have a description of the string like this in my problem description:

String = arbitrary string of letters, digits and symbols, starting and
ending with '"'

As I understand, the requirement said the string can include any kind of
symbols but I really don't know how to implement it. I wrote as the
following but it doesn't work. I would be grateful if someone could give me
some advice. Thanks a million!

STRING : ('a'..'z'|'A'..'Z'
|','
|'='
|'|'
|'/'
|'!'
|'*'
|')'
|']'
|'}'
|':'
|'-'
|'\'
|'"'
|'?'
|'('
|'['
|'{'
|';'
|'.'
|' '
|':'
|'+'
|'_'
|'%'
|'@'
|'&'
|'#'
|'$'
|'<'
|'>'
|'\^'
|'''
|'~')*;


Grace
 


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list