Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Grammar generates extera white space
Xtext Grammar generates extera white space [message #1715863] Thu, 26 November 2015 18:01 Go to next message
Saeed Tajfar is currently offline Saeed TajfarFriend
Messages: 5
Registered: September 2015
Junior Member
Hello everyone!!

I have a Xtext grammar that is generated form an existing ecore file. Here is part of the grammar:


Template returns Template :
'{'
id=ID0 ':' (name=String0)?
'{'
some grammar rules here...
'}'
'}'


Right now, grammar generates this output:
{
ID_VALUE : NAME_VALE
{
}
}


But the expected output is ( both ID and Name values should be surrounded by double quotations,Without any extra White Space ):
I need the grammar to create as output:
{
"ID_VALUE" : "NAME_VALUE"
{
}
}

MY Problem is that if I add the double quotations to the grammar, then it will creates Extra WHITE spaces before and after double quotations; for instance " ID_VALUE " : " NAME_VALUE "

{
" ID_VALUE " : " NAME_VALUE "
{
}
}

Which makes my output invalid!!

Any idea to add double quotations without white spaces?

Thanks in advanced.
Re: Xtext Grammar generates extera white space [message #1715864 is a reply to message #1715863] Thu, 26 November 2015 18:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I am not sure if i get your question. Do you try to serialize a model using xtext?
You may try id=STRING ':' name=STRING


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 26 November 2015 18:36]

Report message to a moderator

Re: Xtext Grammar generates extera white space [message #1715868 is a reply to message #1715864] Thu, 26 November 2015 19:31 Go to previous message
Saeed Tajfar is currently offline Saeed TajfarFriend
Messages: 5
Registered: September 2015
Junior Member
Perfect, Works!

yes, what I am doing is to convert an XMI model of my Ecore metamodel to obtain a json file as output by running the grammar is standalone mode.

the Xtext project type is: "xtext project from existing ecore models".

I forgot to say that string0 and ID are defined as following inside the grammar:

ID0 returns type::ID:
'ID' /* TODO: implement this rule and an appropriate IValueConverter */;

String0 returns type::String :
'String' /* TODO: implement this rule and an appropriate IValueConverter */;



[Updated on: Thu, 26 November 2015 19:43]

Report message to a moderator

Previous Topic:Out of memory Xtext RC1 (IDEA)
Next Topic:Xtext build with maven and mixed Xtend/Java projects
Goto Forum:
  


Current Time: Thu Apr 25 12:09:27 GMT 2024

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

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

Back to the top