Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » \n in xtext
\n in xtext [message #669696] Wed, 11 May 2011 08:10 Go to next message
adrian  is currently offline adrian Friend
Messages: 93
Registered: August 2009
Member
Hi all ,
In my grammer I define a terminal rule as :
terminal body : <body> -> </body>
so I can define any java expression inside this body.
The problem happens when I define for example:
<body> String NL="\n"; </body> I lose the expression \n and is mapped to 'new line' so when I extract my model I have :

<body> String NL="
"; </body>
Which is not what I want
any idea ? thanks in advance
Re: \n in xtext [message #669707 is a reply to message #669696] Wed, 11 May 2011 08:41 Go to previous messageGo to next message
Luong  is currently offline Luong Friend
Messages: 8
Registered: March 2011
Junior Member
Hi!
Are you using the default Terminal rules? I mean org.eclipse.xtext.common.Terminals.

If so, you should write "YourString\\n".

L.
Re: \n in xtext [message #669711 is a reply to message #669707] Wed, 11 May 2011 08:58 Go to previous messageGo to next message
adrian  is currently offline adrian Friend
Messages: 93
Registered: August 2009
Member
Hi Luong,
Yes I m using the default terminal rules

[Updated on: Wed, 11 May 2011 08:59]

Report message to a moderator

Re: \n in xtext [message #669718 is a reply to message #669696] Wed, 11 May 2011 09:20 Go to previous messageGo to next message
Luong  is currently offline Luong Friend
Messages: 8
Registered: March 2011
Junior Member
Allright and writing "\\n" instead of "\n" had worked?
Smile

L.

[Updated on: Wed, 11 May 2011 09:23]

Report message to a moderator

Re: \n in xtext [message #669723 is a reply to message #669718] Wed, 11 May 2011 09:31 Go to previous messageGo to next message
adrian  is currently offline adrian Friend
Messages: 93
Registered: August 2009
Member
Not really because I must intercede manually to add \
I wonder if there is a possibility to change the default \n for xtext to be different to java for example \$ will be the new line expression in xtext ??
Re: \n in xtext [message #669729 is a reply to message #669696] Wed, 11 May 2011 09:23 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Piko,

you'll have to provide an own value converter for your 'body' terminal
rule which does not replace escaped text.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 11.05.11 10:10, schrieb piko:
> Hi all ,
> In my grammer I define a terminal rule as :
> terminal body : <body> -> </body> so I can define any java expression
> inside this body.
> The problem happens when I define for example:
> <body> String NL="\n"; </body> I lose the expression \n and
> is mapped to 'new line' so when I extract my model I have :
>
> <body> String NL="
> "; </body>
> Which is not what I want any idea ? thanks in advance
Re: \n in xtext [message #669730 is a reply to message #669723] Wed, 11 May 2011 09:39 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Piko,

you'll have to implement a value converter for your terminal rule.
Please refer to the docs for details.

Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 11.05.11 11:31, schrieb piko:
> Not really because I must intercede manually to add \
> I wonder if there is a possibility to change the default \n for xtext to
> be different to java for example \$ will be the
> new line expression in xtext ??
Previous Topic:Re: &quot;Greedy&quot; Content Assist
Next Topic:Slow Ecore->Xtext serialization
Goto Forum:
  


Current Time: Fri Apr 19 20:25:40 GMT 2024

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

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

Back to the top