Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Hidden fields in the grammar?
Hidden fields in the grammar? [message #709093] Wed, 03 August 2011 13:55 Go to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Hey guys!

Another day, another question Smile
I was wondering if there is, lets say, a keyword in the Xtext grammar language for hiding a then defined attribute from the user.
Which means in the Statemachine example I could define an additional "type" like:

Event :
  name=ID code=ID type=String; 


But then "type" should be hidden from the scoping, outline etc. BUT it should be generated in the EMF Model, so that I can access it through the resource.

Does anyone know if there is something to accomplish that?
Thanks a lot Smile

Best regards,
Daniel
Re: Hidden fields in the grammar? [message #990543 is a reply to message #709093] Thu, 13 December 2012 00:31 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevittFriend
Messages: 70
Registered: December 2012
Location: Belfast
Member
I was looking for this as well but see no one else has replied. Did you find something?

I am trying this -

Event :
name=ID code=ID ('MyHiddenEventType' type=String)? ;

The block containing 'type' is optional and starts with an unlikely fixed text so it does not have to appear in the input and the parser can skip over it. The secret fixed text does not appear in the model either of course.

This means Event now has a type field in the generated model which you can use to set and get during the generation and validation phases, but it's not required to be present in the input language.

Depending on how many other optional levels you have in your grammar you may need to add some syntactic predicates to help out the parsing so add the '=>' to guide the parser into doing this branch ahead of any higher ones.

(=> 'MyHiddenEventType' type=String)?

Hope this works. I've only started trying it and having some other problems with trying to apply it on every rule, but it basically seems to work although I'd welcome knowing about a more formal method if there is one.
Re: Hidden fields in the grammar? [message #990689 is a reply to message #990543] Thu, 13 December 2012 19:52 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

use a manually maintained metamodel or do something like http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:specification of algorithms for code generation in different langs
Next Topic:Formatting with range: Does this also apply to everything within that range?
Goto Forum:
  


Current Time: Fri Mar 29 02:13:23 GMT 2024

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

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

Back to the top