Parsing strings with quotes....

View: New views
2 Messages — Rating Filter:   Alert me  

Parsing strings with quotes....

by Alexander James-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I'm trying to parse a language where single quotes are allowed within  
strings that are themselves enclosed within the same quotes without an  
escape character being used.
E.g. 'This is how you'''d use an apostrophe'

At the moment I'm defining a string within single quotes as the  
following:

<QUOTED_STRING: "\'" (~["\'"])* "\'">

Has anyone got an suggestions on I could handle this?

Cheers,


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


RE: Parsing strings with quotes....

by Mazas Marc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try this ?

<QUOTED_STRING: "\'" (~["\'"])* ( "\'\'\'" (~["\'"])* )* "\'">

You should also extend this if you can have two apostrophes in a row


Marc MAZAS


-----Message d'origine-----
De : Alexander James [mailto:earwigboy@...]
Envoyé : dimanche 25 octobre 2009 17:55
À : users@...
Objet : [JavaCC] Parsing strings with quotes....

Hi All,

I'm trying to parse a language where single quotes are allowed within strings that are themselves enclosed within the same quotes without an escape character being used.
E.g. 'This is how you'''d use an apostrophe'

At the moment I'm defining a string within single quotes as the
following:

<QUOTED_STRING: "\'" (~["\'"])* "\'">

Has anyone got an suggestions on I could handle this?

Cheers,


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...