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

Tilman Bender tbender at stud.hs-heilbronn.de
Thu Jun 4 09:55:14 PDT 2009


Hi Xiaohua,

Try this one:

STRING :
   '"' (~('"'|'\n'|'\r'))* '"';

It says the string starts with " and ends with " while an between  
those there can be any character but ",\n or \r
This was taken from the templates used in the ANTLRIDE editor.

HTH

Tilman Bender
Student des Software Engineering
Hochschule Heilbronn
tbender at stud.hs-heilbronn.de



Am 04.06.2009 um 18:45 schrieb Xiaohua Guo:

> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090604/9df172e1/attachment.html 


More information about the antlr-interest mailing list