How to have both cross references and non cross references for a rule? [message #1850005] |
Thu, 10 February 2022 11:58  |
Eclipse User |
|
|
|
Hi,
I am facing this issue in my xtext grammar.
My usecase is that I need to have both references and non references as part of a single rule. Below is my grammar
Entity:
entityName='Sample' name=INTID '{'
(attrList+=(DefinedAttribute|NonDefinedAttribute))*
'}');
DefinedAttribute:
name=[ValueAttributeDefinition] ':' value=INT;
NonDefinedAttribute:
name=ID ':' value=INT;
ValueAttributeDefinition:
'Attribute' name=ID '{'
'}';
As part of this Entity I need to have attributes which are defined as part of ValueAttributeDefinition as well as Extra attributes which are not defined and not references to ValueAttributeDefinition.
But the problem is since ValueAttributeDefinition is also an ID internally, all attributes are getting parsed as DefinedAttribute. Please help in resolving this.
Sample data file below
Attribute proper_attribute {
}
Sample 12234 {
abc: 123
proper_attribute: 456
}
In the above data abc is also getting considered as DefinedAttribute during parsing.
Does anyone know how to resolve this?
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.50270 seconds