Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » definition terminal STRING(backslash character in STRING)
definition terminal STRING [message #1729907] Wed, 20 April 2016 08:33 Go to next message
Jia Poh Kow is currently offline Jia Poh KowFriend
Messages: 25
Registered: November 2015
Junior Member
Hi,

I found that the default terminal STRING is as below:

terminal STRING :
'"' ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|'"') )* '"' |
"'" ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|"'") )* "'"
;

Question 1:
From the definition, isn't that 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' is commented?
It is not implementing inside already right?

Question 2:
. should be accepting anything right?

Come back to my problem.
When i used STRING, it seems that it cannot accept syntax like tis.
"NXTBINARY\0\0\0"
It gives me an error saying invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\)
However, I need something like \0

Any idea on this?
Thank you.
Re: definition terminal STRING [message #1729911 is a reply to message #1729907] Wed, 20 April 2016 08:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you want to do what java does with

"NXTBINARY\\0\\0\\0"

the same should work in xbase.

(escape is \\)

\0 is forbidden by STRINGValueConverter



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: definition terminal STRING [message #1729914 is a reply to message #1729911] Wed, 20 April 2016 08:58 Go to previous messageGo to next message
Jia Poh Kow is currently offline Jia Poh KowFriend
Messages: 25
Registered: November 2015
Junior Member
Hi Christian,

Not sure if I got you right. Do you mean Java is not accepting
String ab ="NXTBINARY\0\0\0";
as well?

But, I checked it has no errors for this String ab ="NXTBINARY\0\0\0"; to run in java.

Re: definition terminal STRING [message #1729915 is a reply to message #1729914] Wed, 20 April 2016 09:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
no i was asking if you want to have \0 (0 Byte) or \\0.

the StringValueConverter does not allow that.

you have to use \u0000


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: definition terminal STRING [message #1729918 is a reply to message #1729915] Wed, 20 April 2016 09:26 Go to previous messageGo to next message
Jia Poh Kow is currently offline Jia Poh KowFriend
Messages: 25
Registered: November 2015
Junior Member
oh, i wan to have \0 which means null in unicode.

I cannot change the syntax to /u0000 as I am developing an editor for the existing language where the syntax is fixed to be \0

I read the StringValueConverter. Is it possible for me to override the class and add in another switch case?
Re: definition terminal STRING [message #1729919 is a reply to message #1729918] Wed, 20 April 2016 09:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
yes override the valueconverterserivce for your dsl

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: definition terminal STRING [message #1729920 is a reply to message #1729919] Wed, 20 April 2016 09:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
or add a binding for STRINGValueCOnverter

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: definition terminal STRING [message #1729927 is a reply to message #1729919] Wed, 20 April 2016 10:09 Go to previous message
Jia Poh Kow is currently offline Jia Poh KowFriend
Messages: 25
Registered: November 2015
Junior Member
okok...it works well now.
Thankz Christian =)

Previous Topic:Regarding ignoreCase for Keywords.
Next Topic:Xtext dynamic content assist without typing ctrl+space
Goto Forum:
  


Current Time: Fri Mar 29 14:42:15 GMT 2024

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

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

Back to the top