Game Development Reference
In-Depth Information
The reference model in this example holds three of these weapon type definitions, but in practice there might be
an arbitrary number of definitions per file. You can derive a rule that your Model consists of an arbitrary number of
TypeDefinitions :
Model: typeDefinitions+=TypeDefinition* ;
In Xtext, this line means that you have a root element called Model that holds a list of elements of type
TypeDefinition . Now, how is TypeDefinition defined? Every single definition starts with the keyword Define ,
optionally followed by the keyword type . After that, an identifier has to follow. After a colon, the three properties for a
weapon type have to be declared. In Xtext, this can look like Figure 13-7 .
Figure 13-7. Language definition (concrete syntax) for weapon types in Xtext (top), showing the automatically
generated abstract syntax as ecore model (bottom)
Similarly, you can derive the grammar rules for the weapon definition language. For the different outputs
suggested in the example above, the description of the corresponding implementation would go beyond the scope of
this chapter and might well cost a lot of resources.
Search WWH ::




Custom Search