Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using element define in one grammar into another(i wanted to use the element which i have created in one xtext into another xtext)
Using element define in one grammar into another [message #695213] Mon, 11 July 2011 09:45 Go to next message
irfan  is currently offline irfan Friend
Messages: 16
Registered: July 2011
Junior Member
Hi all,
i have a file style.xtext which looks as follow:
External_Style:
	'{'
	('"fill"' ':' fill=(Color | Fill_gradient) (',')?)?
	('"outline"' ':' outline=Color (',')?)?
	('"stroke"' ':' stroke=Stroke (',')?)?
	('"symbol"' ':' symbol=STYLE_SYMBOL (',')?)?
	('"orientation"' ':' orientation=STYLE_ORIENTATION (',')?)?
	('"padding"' ':' padding=(NUMBER | PERCENTAGE) (',')?)?
	('"size"' ':' size=(NUMBER | PERCENTAGE) (',')?)?
	('"font"' ':' font=Font (',')?)?
	('"inside"' ':' inside=STYLE_INSIDE (',')?)?
	('"align"' ':' align=STYLE_ALIGN (',')?)?
	('"valign"' ':' valign=STYLE_ALIGN (',')?)?
	('"effect"' ':' effect=Effect (',')?)?
	'}';


Now i want to use the Style element into another file like this...
VizSpec:
	'{' '"data"' ':' data=(DataEntity | DataArray) ','
	'"grammar"' ':' vizGrammar=(GrammarEntity | GrammarArray) 
	(',' '"legends"' ':' legends=(LegendsEntity | LegendsArray))?
	(',' '"size"' ':' size=Size)?
	(',' '"style"' ':' style=External_Style)?
	'}';

Can any one please provide a solution for it...
I have basically divided the entire grammar into two...
one file containing style element and the other the rest of it...
Code given above is not the whole file....just the part of it...
Thanks in advance
Irfan.
Re: Using element define in one grammar into another [message #695227 is a reply to message #695213] Mon, 11 July 2011 10:18 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

I guess in VizSpec you want to use the style defined in the other file. That means you want a cross reference:
VizSpec:
'{' '"data"' ':' data=(DataEntity | DataArray) ','
'"grammar"' ':' vizGrammar=(GrammarEntity | GrammarArray)
(',' '"legends"' ':' legends=(LegendsEntity | LegendsArray))?
(',' '"size"' ':' size=Size)?
(',' '"style"' ':' style=[External_Style])? //changed to cross reference here
'}';

But an object can only be referenced, if it has a name

External_Style: name=ID
'{'...;

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Using element define in one grammar into another [message #695251 is a reply to message #695227] Mon, 11 July 2011 11:35 Go to previous messageGo to next message
irfan  is currently offline irfan Friend
Messages: 16
Registered: July 2011
Junior Member
thanks for the rply...
now its recognizing the style element,but now when i open my editor it does not provide content assistant for style and does no even recognize its sub element as keywords....

thanks
Irfan

[Updated on: Mon, 11 July 2011 11:35]

Report message to a moderator

Re: Using element define in one grammar into another [message #695272 is a reply to message #695251] Mon, 11 July 2011 12:10 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

it is not really clear what you want to achieve. Do you want to define the style within the VizSpec-element or do you want to "reuse" a style defined elsewhere. My solution was for the second case. Of course, your grammar must allow for the Style to be defined somewhere.

Model: 'styles' (styles+=External_Style)* 'vizspecs' (vizspec+=VizSpec)*

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Using element define in one grammar into another [message #695278 is a reply to message #695272] Mon, 11 July 2011 12:20 Go to previous messageGo to next message
irfan  is currently offline irfan Friend
Messages: 16
Registered: July 2011
Junior Member
hi,
i already have a style define in project,now i want to use that style in an another project,which is vizspec...

thanks
irfan

[Updated on: Mon, 11 July 2011 12:20]

Report message to a moderator

Re: Using element define in one grammar into another [message #695282 is a reply to message #695278] Mon, 11 July 2011 12:27 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
This still does not anwer the question whether you want to reuse the grammar for style, so that you can define a new style inline in a vizspec element or whether you simply want to cross reference to an existing style definition in another model file.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Using element define in one grammar into another [message #695302 is a reply to message #695282] Mon, 11 July 2011 13:18 Go to previous messageGo to next message
irfan  is currently offline irfan Friend
Messages: 16
Registered: July 2011
Junior Member
Hi,
I'll try to be as clear as possible...i want to use style in vizspec by referencing it with style which i hv already created...i dnt want to give an inline defination of it....i simply want my style in vizspec to be able to refer external style.
Thanks for ur rply,
Irfan.
Re: Using element define in one grammar into another [message #695312 is a reply to message #695302] Mon, 11 July 2011 13:29 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

so you want a cross reference. That is, my first post points into the direction you want to go.
You will have to make sure that at least the following conditions are met:
-the style defined in file X is exported (bydefault if it has a name) use "Open Model Element" (shift ctrl F3) to check whether you can find the style in the index
-the style is visible from the vizspec model (if style is in another project, you need a project dependency to that project or have it on the classpath somehow)
-in case the style has a "qualified name", referencing must be done via a corresponding syntax (e.g. [External_Style|Fqn] instead of [External_Style]

I still don't quite understand whether you are working with one or several grammars, i.e. languages (style and vizspec model files have different file extensions).

Alex

P.S.: Hints can only be as specific as the questions and the provided details are.


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Using element define in one grammar into another [message #695322 is a reply to message #695312] Mon, 11 July 2011 13:52 Go to previous messageGo to next message
irfan  is currently offline irfan Friend
Messages: 16
Registered: July 2011
Junior Member
Hi alex,
The vizspec and style both have same extension,actually style was part of vizspec grammar it self...but then the size of grammar was too large...an it gave an error in src_gen that the size of some java file cannot be greater then 65kb...which was later register as a bug...so unless the xtext team can come up with a solution of it i was kind of stuck...so i decided to break the grammar into two parts...
Re: Using element define in one grammar into another [message #695324 is a reply to message #695322] Mon, 11 July 2011 13:55 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

so you are saying that you have two different languages that register the same file extension?

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Using element define in one grammar into another [message #695328 is a reply to message #695324] Mon, 11 July 2011 14:04 Go to previous message
irfan  is currently offline irfan Friend
Messages: 16
Registered: July 2011
Junior Member
Yes...because i am not aware of any other way to split the grammar...so i created two different grammar...
Previous Topic:Unordered group problem
Next Topic:C# like #region Preprocessor
Goto Forum:
  


Current Time: Tue Apr 16 20:14:34 GMT 2024

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

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

Back to the top