Skip to content

Latest commit

 

History

History
277 lines (166 loc) · 4.55 KB

ExampleDomainmodelDocs.md

File metadata and controls

277 lines (166 loc) · 4.55 KB

Domain model grammar documentation

Example model from the Xtext documentation, see Xtext webpage.

Extended with documentation for demonstration purposes.

Included grammars:

  • org.eclipse.xtext.common.Terminals

Rules

Domainmodel

A domain model is a collection of elements.

This is the root element of the grammar.

Refers to:

Domainmodel:
    (elements+=AbstractElement)*;

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;

PackageDeclaration

A package has a qualified name and elements inside.

  • Validation:
    • The package name shall not start with letter P.

Refers to:

Referred by:

PackageDeclaration:
    'package' name=QualifiedName '{'
        (elements+=AbstractElement)*
    '}';

Import

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;

QualifiedName

A qualified name has one or more segments with . as separators.

Refers to:

  • ID

Referred by:

Returns: ecore::EString

QualifiedName:
    ID ('.' ID)*;

QualifiedNameWithWildcard

A qualified name, optionally with a wildcard (*) last segment.

Refers to:

Referred by:

Returns: ecore::EString

QualifiedNameWithWildcard:
    QualifiedName '.*'?;

Type

A type is either an atomic data type (DataType), or an entity (Entity), containing several features.

Refers to:

Referred by:

Type:
    DataType | Entity;

DataType

A data type is an atomic named type.

Refers to:

  • ID

Referred by:

DataType:
    'datatype' name=ID;

Entity

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)*
    '}';

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];

DummyEnum (enum)

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' 
;

Simplified grammar

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;

Rule dependencies

Rule dependencies