Skip to main content



      Home
Home » Modeling » TMF (Xtext) » String rule to support double quotes inside String(String rule to support double quotes inside String)
String rule to support double quotes inside String [message #1795301] Thu, 20 September 2018 02:45 Go to next message
Eclipse UserFriend
Hello,

I am trying to support double quotes inside string.
STRING terminal rule is not allowing double quotes inside string.
e.g
"THERE SHOULD BE 55 SPACES BETWEEN ""B"" AND ""C""." 


Is it possible to achieve this?
Need some suggestion is this regard.

Thanks and regards,
Virag Purnam
Re: String rule to support double quotes inside String [message #1795306 is a reply to message #1795301] Thu, 20 September 2018 04:37 Go to previous messageGo to next message
Eclipse UserFriend
how does your string literal look like? did you simply adopt the existing one in the straight forward way?

@Override
terminal STRING:
'"' ( '""' | !('"') )* '"';

p.s.: dont forget to adapt the value converter

Re: String rule to support double quotes inside String [message #1795307 is a reply to message #1795306] Thu, 20 September 2018 04:51 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the reply Mr. Christian Dietrich,
@Override 
terminal STRING 	: 
			('"'!('"')*'"' |
		     "'"!("'")*"'"		
			) 
;


Thanks for the hint. I will try with the rule, which you have proposed.
Re: String rule to support double quotes inside String [message #1795375 is a reply to message #1795307] Fri, 21 September 2018 02:00 Go to previous message
Eclipse UserFriend
Thanks.
This works for me.
Previous Topic:Testing the Syntax/Semantic highlights
Next Topic:Couldn't resolve reference to grammer
Goto Forum:
  


Current Time: Sat Jun 21 15:39:42 EDT 2025

Powered by FUDForum. Page generated in 0.04511 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top