Example model from the Xtext documentation, see Xtext webpage.
Extended with documentation for demonstration purposes.
Included grammars:
org.eclipse.xtext.common.Terminals
A domain model is a collection of elements.
This is the root element of the grammar.
Refers to:
Domainmodel:
(elements+=AbstractElement)*;
An element is a package declaration, import or type.
This is the root element of the grammar.
Refers to:
Referred by:
AbstractElement:
PackageDeclaration | Type | Import;
A package has a qualified name and elements inside.
- Validation:
- The package name shall not start with letter
P
.
- The package name shall not start with letter
Refers to:
Referred by:
PackageDeclaration:
'package' name=QualifiedName '{'
(elements+=AbstractElement)*
'}';
An import makes available another namespace.
The imported namespace is defined by a qualified name, potential with a wildcard.
Refers to:
Referred by:
Import:
'import' importedNamespace=QualifiedNameWithWildcard;
A qualified name has one or more segments with
.
as separators.
Refers to:
- ID
Referred by:
Returns: ecore::EString
QualifiedName:
ID ('.' ID)*;
A qualified name, optionally with a wildcard (*
)
last segment.
Refers to:
Referred by:
Returns: ecore::EString
QualifiedNameWithWildcard:
QualifiedName '.*'?;
A type is either an atomic data type (DataType), or an entity (Entity), containing several features.
Refers to:
Referred by:
Type:
DataType | Entity;
A data type is an atomic named type.
Refers to:
- ID
Referred by:
DataType:
'datatype' name=ID;
An entity is a named structure of features. It can extend another entity, in this case the features of the extended entity will also be contained by this one.
Refers to:
Referred by:
Entity:
'entity' name=ID ('extends' superType=[Entity|QualifiedName])? '{'
(features+=Feature)*
'}';
A feature is a named reference to one or many objects of the given type.
Refers to:
Referred by:
Feature:
(many?='many')? name=ID ':' type=[Type|QualifiedName];
A dummy enum to demonstrate its documentation.
Literals:
- One (
ONE
) : Representation of number 1. - Three (
THREE
) : Representation of number 3. - Two (
TWO
,ZWEI
) : Representation of number 2.
enum DummyEnum:
One = 'ONE' |
Two = 'TWO' | Two = 'ZWEI' |
Three = 'THREE'
;
Domainmodel ::= AbstractElement*;
AbstractElement ::= PackageDeclaration | Type | Import;
PackageDeclaration ::= package
QualifiedName {
AbstractElement* }
;
Type ::= DataType | Entity;
Import ::= import
QualifiedNameWithWildcard;
QualifiedName ::= ID (.
ID)*;
DataType ::= datatype
ID;
Entity ::= entity
ID (extends
QualifiedName)? {
Feature* }
;
QualifiedNameWithWildcard ::= QualifiedName .*
?;
ID ::= ^
? ([a
..z
] | [A
..Z
] | _
) ([a
..z
] | [A
..Z
] | _
| [0
..9
])*;
Feature ::= many
? ID :
QualifiedName;