Terminal Rule Token based on previous crossreference [message #1745587] |
Wed, 12 October 2016 19:06  |
Matt Se Messages: 29 Registered: February 2016 |
Junior Member |
|
|
Hi,
I have a grammar which kinda looks like this
Element returns datatypes::Element:
{datatypes::Element}
(refVars+=[wrapper::Variable|QualifiedName] ':' TYPE_NAME)* /*the typename should equal to variable.type.name*/
;
Variable returns datatypes::Variable:
{datatypes::Variable}
name=EString
type=[ecore::EObject|EString] /* the info about the name is relevent for the crossreference*/
;
terminal TYPE_NAME:
'DOUBLE' | 'INT' | 'LONG'
;
So my element has references to a Variable, which has a specific type.
Now I want to display the name of the type after the crossreference, but only display and not assign another crossreference.
I tried this with a terminal rule.
And found my generated org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer a method which looks like this:
protected String getTYPE_NAMEToken(EObject semanticObject, RuleCall ruleCall, INode node) {
if (node != null)
return getTokenText(node);
return "DOUBLE";
}
now I can return a specific String based on the semanticObject, but the semantic EObject is always the Element Object and I'm not able to identify to the Variable for which I return the String. Since the node is always null I can't figure out the current crossreference assignment.
How can display (only display, not assign anything) a specific String after a corssreference?
Many thanks in advance
[Updated on: Wed, 12 October 2016 19:13] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02456 seconds