|Re: Xtext Symbol [message #1746158 is a reply to message #1746113]
||Mon, 24 October 2016 08:32
| Jan Koehnlein
Registered: July 2009
There is no built-in notion of a Symbol. In Xtext, rules create instances of a class model when they are processing the text. The example says that the rule Name returns an instance of the class Symbol when it matches. The definition of classes like Symbol are, depending on the model definition in your grammar, either derived from the grammar or imported from an existing Ecore model.|
You can build any kind of inheritance hierarchy in the Ecore model, e.g. by defining
SymbolVar | SymbolConst | SymbolData | SymbolModule;
You will make SymbolVar etc. inherit from Symbol, even if you never call the rule explicitly. Common features, e.g. a String attribute called name will be uplifted to the super class.
A cross-reference to a Symbol, as in you Ref rule, can then point to any subclass of Symbol. For the details of the linking and the special meaning of an attribute called name, please read the docs.
Have a look at the Grammar section of Xtext documentation for details on the Ecore model / Xtext relationship.
Get professional support from the Xtext committers at www.typefox.io
Powered by FUDForum
. Page generated in 0.03556 seconds