I'm new to working with Xtext and Xtend and I have stumbled upon a problem which I hope someone can help me solve. What I'm trying to achieve is to resolve variables from an external source rather than declaring them explicitly in the DSL. I got the following example to demonstrate: Here is the grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
configUrl=ConfigUrl
devices+=Device*
test=Test
;
ConfigUrl:
"ConfigURL=" url=STRING
;
Device:
'Device' name=ID
'has channels: ' (channels+=Channel (',' channels+=Channel)*)?
;
Channel:
name=ID
;
Test:
'DoSomething' channel=[Channel|QualifiedName]
;
and here is an example usage:
ConfigURL="http://localhost:8080/devices"
Device Light has channels: state
DoSomething Light.state
Instead of explicitly declaring the devices in the DSL I would like to resolve them from and external source (the ConfigURL variable). As far as I can tell, what I'm looking for is related to the scoping functionality of Xtend. I have looked at the documentation but haven't found much that can help me further. In addition, it seems that some things has changed and the examples that I've come across are outdated.
Thanks,