Setting up URI imports [message #734490] |
Fri, 07 October 2011 21:02  |
Eclipse User |
|
|
|
I've read a lot about using 'uri imports' but somehow I still cannot make it
work for my toy grammar. I implemented
- the ScopeProvider (for local scope),
- the name provider (a simple name provider-- used during exporting),
- modified the 'language workflow
(e.g., add fragment = scoping.ImportURIScopingFragment {},
remove scoping.ImportNamespacesScopingFragment {}, etc.).
Somehow I'm still missing one step (attached is the complete code).
Here is my grammar:
grammar org.xtext.example.globalScope.FilePrint with org.eclipse.xtext.common.Terminals
import "ALINK_HERE //www.eclipse.org/emf/2002/Ecore" as ecore
generate filePrint "A LINK HERE//www.xtext.org/example/globalScope/FilePrint"
//^^^^ I put 'ALINK HERE' instead of http: so I could post this question
Model:
(imports+=Import)*
(images+=Image | prints+=PrintCmd)*
;
Image:'image' fileName= ID ';' ; //NOTE I don't use 'name' here ..
PrintCmd: 'print' image=[Image | FNQ] ';' ; //Is this correct? saw in some posts ..
FNQ returns ecore::EString : ID;
Import : 'import' importURI=STRING ';' ; // feature must be named importURI
All I want is for the 'PrintCmd' rule to be able to refer to 'Images' defined in other
file. For instance, I created a eclipse project with the following two files. The content of file1.deleteMe (deleteMe is the extension of my DSL):
import "file2.deleteMe";
image anImage ;
print anImage;
print anotherImage; //this gives a 'linking' error
and file2.deleteMe
image anotherImage ;
print anotherImage;
Any suggestions? Thanks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04472 seconds