Relational growth grammars describe an abstract concept.
The programming language XL is a concrete implementation of this
concept. All examples of the tutorial are written in XL, so you
already have seen some XL source code.
The purpose of this tutorial is not to give a full specification of the
XL programming language, for this the reader is referred to the
XL language specification at
https://manual.grogra.de/XL/
.
Perhaps the most important feature of XL is that it is an extension of Java: Everything that can be written in Java can be written in XL, too. Every existing library of Java classes can be imported and used. You should read at least some introductory literature on Java in order to get familiar with this part of XL. In the sequel, the tutorial will make use of terms of the Java language like classes, instances, fields, methods, and constructors.
Let us reconsider the very first example of this tutorial. Its XL source code looked like this:
public void derivation() [ Axiom ==> F RU(120) F RU(120) F; F ==> F RU(-60) F RU(120) F RU(-60) F; ]
Having said that XL is an extension of Java, the parts of this code can now be seen from the perspective of Java: In Java, methods can be declared as in
public void derivation() { doSomething(); }
In XL, this is the same, so the example declares a method named
derivation
. However, in XL there is the possibility
to write a block enclosed in square brackets []
whereever Java allows just a block enclosed in curly braces
{}
. Within a block enclosed in square brackets,
rules are specified, whereas a block enclosed in curly braces
contains conventional Java statements.
As has been said earlier in this tutorial, the names
Axiom
, F
, RU
correspond to Java classes of that name (in this case
in the package de.grogra.turtle
). The left hand side
of the rule Axiom ==> F RU(120) F RU(120) F;
has to
be understood as a pattern which matches for every instance of the class
Axiom
. Now for every such instance
which can be found in the graph, the replacement operator
==>
replaces the instance by the right hand side,
which in this case consists of a linear graph of five nodes. These
nodes are newly created ones, because F
and
RU(120)
are interpreted as constructor invocations
(in Java, one would write new F()
and
new RU(120)
). The new nodes are connected by
a default successor
edge which indicates that
they are simply written one after another.