Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Ambiguous Grammar?
Ambiguous Grammar? [message #888650] Mon, 18 June 2012 12:25
Nicola Serreli is currently offline Nicola SerreliFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

I'm trying to implement an editor for Osek-vdx Oil grammar using xtext.
The language contains two main sections, the first one is used to describe the list of attributes and valid values of the second one.

For example, in the first part we say that a TASK is composed by
- an Integer, named "PRIORTY"
- a reference to an EVENT, named "EVENT"
- an enumerate named "SCHEDULE" with values NON and FULL
here is how express it through oil syntax
TASK { // inside the first section
   UINT32 PRIORITY;  // handled as ValueType
   EVENT_TYPE EVENT[]; // handled as VariantType
   ENUM [NON, FULL] SCHEDULE;  // handled as ReferenceType
};



then, we instantiate a task "t1" with following values using the oil syntax:
TASK t1 { // inside the second section
   EVENT=ev1;
   PRIORITY=1;
   SCHEDULE=NON;
};


what happens is that the only way to understand what should be expected after the "=" is to resolve the link the ID (EVENT, PRIORITY, SCHEDULE) to the corresponding element in the first section

There is a way to handle this three different kind of attribute with three different classes in the model? i.e. writing something like


Attribute returns Attribute:
	Value | Reference | Enumerator;

Value returns Value:
	{Value}
	Type=[ValueType|ID]
	'=' Value=INT
	";"
;

Enumerator returns Enumerator:
	{Enumerator}
	Type=[ParameterType|ID]
	"=" Value=[EnumeratorType|ID]
	";"
;

Reference returns Reference:
	{Reference}
	Type=[ReferenceType|ID]
	'=' Value=[OilObject|ID]
	";"
;

Previous Topic:EMF Notifications via Xtext index
Next Topic:Questions about ImportUriGlobalScopeProvider
Goto Forum:
  


Current Time: Thu Apr 25 06:36:07 GMT 2024

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

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

Back to the top