Importing Existing Ecore Models

With the import directive in Xtext you can refer to existing Ecore models and reuse the types that are declared in an EPackage. Xtext uses this technique itself to leverage Ecore data types.

import 'http://www.eclipse.org/emf/2002/Ecore' as ecore

Specify an explicit return type to reuse such imported types. Note that this even works for terminal rules.

terminal INT returns ecore::EInt : ('0'..'9')+;