Hello,
I have defined a grammar
grammar a.Dsl with org.eclipse.xtext.common.Terminals
...
Model:
greetings+=Greeting*;
Greeting:
Definition|Application;
Definition:
'Def' name=ID '.';
Application:
'App' def = [Definition] '.';
and I try to parse in a standalone application:
public static void main(String[] args) {
String str = "Def var."//
+ "App var.";
Injector injector =
new DslStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
DslParser tp = injector.getInstance(DslParser.class);
Reader r = new StringReader(str);
IParseResult pr = tp.doParse(r);
Model m = (Model) pr.getRootASTElement();
Application a = (Application) m.getGreetings().get(1);
Definition def = a.getDef();
//def is null
System.out.println(def);
}
Why a value of the attribute ´def´ is not set in the selected node of the AST (Definition)? I guess that it is required to run linking but I don´t know how. Is there anybody how could help me.
Thank you
Jan