chapter:DomainmodelNextSteps[15 Minutes Tutorial - Extended]

After you've developed you first own DSL, the question arises, how the behavior and the semantics of
the language can be customized. Therefore a couple of mini-tutorials are available, that illustrate common
use cases when crafting an own DSL.

These lessons are independent from each other. Each of them will be based on the language that
was build in the first ref:DomainmodelWalkThrough[domain model tutorial].

That is, the syntax and the grammar for the language look like this:

code[DomainExample][
package java.lang {
	datatype String
}

package my.company.blog {
	import java.lang.*
	import my.company.common.*
	  
	entity Blog {
		title: String
		many posts: Post
	}
	
	entity HasAuthor {
		author: String
	}
	
	entity Post extends HasAuthor {
		title: String
		content: String
		many comments: Comment
	}
	
	entity Comment extends HasAuthor {
		content: String
	}
}
]

code[Xtext][
grammar org.eclipse.xtext.example.Domainmodel with
                                      org.eclipse.xtext.common.Terminals

generate domainmodel "http://www.eclipse.org/xtext/example/Domainmodel"

Domainmodel:
  (elements += AbstractElement)*
;

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

AbstractElement:
  PackageDeclaration | Type | Import
;

QualifiedName:
  ID ('.' ID)*
;

Import:
  'import' importedNamespace = QualifiedNameWithWildcard
;
  
QualifiedNameWithWildcard:
  QualifiedName '.*'?
;
  
Type:
  DataType | Entity
;
  
DataType:
  'datatype' name=ID
;
 
Entity:
  'entity' name = ID 
              ('extends' superType = \[Entity | QualifiedName\])?
  '{'
    (features += Feature)*
  '}'
;
 
Feature:
  (many ?= 'many')? name = ID ':' type = \[Type | QualifiedName\]
;
]

section-ref[TutorialCodeGeneration]

section-ref[TutorialUnitTests]

section-ref[TutorialValidation]