This section presents the complete grammar of the statechart language. If you are in doubt how to write down a transition specification, a variable declaration, or any other syntactical construct of the itemis CREATE statechart language, this is your definite reference that clarifies all syntactical questions.
The grammar is visualized using railroad diagrams. Railroad diagrams are easy to read and comprise all syntactically valid language constructs. Figure "Railroad diagrams explained" shows an example:
Railroad diagrams explained
On the left-hand side you’ll find the so-called non-terminal symbol (or non-terminal for short) that is being defined by this particular diagram. Here the non-terminal is SimpleElementReferenceExpression. To find out what a SimpleElementReferenceExpression is allowed to look like, follow the “railroad track” just like a train would do. At each junction, the train either keeps its direction or changes it by 45 degrees, but it cannot make sharp turns of 90 degrees or more.
On its way, the train passes several “stations”. Each station represents a language element that is valid at this point. In our example, the first station is a rectangle with a grey background. The grey background denotes a non-terminal, and the word inside the rectangle is the non-terminal’s name, here: ID. You will have to look up this particular non-terminal’s railroad diagram to learn more about it. However, for simplicity and because their meanings are more or less obvious, a few non-terminals are not refined further. Examples are STRING, INT, BOOL, or ID.
In a
SimpleElementReferenceExpression, a valid ID – a name – is always the first element, e.g.,
init42
. If the train turns right at the junction, it moves directly to the railroad diagram’s exit. That means an
ID like
init42
is a valid
SimpleElementReferenceExpression. Please note that when the train reaches the junction right before the exit, it cannot turn left, because trains don’t move that way. That is, the train is unable to travel to the
(
station.
The train can reach the
)
from the opposite direction only. After having left the initial
ID station, the train can move to the left at the junction and then run a stretch touching only the
(
and
)
stations, in that order. These rectangles have a white background color, denoting a
terminal symbol
or
terminal for short. A terminal stands for itself; write it down as it is.
Following that rule,
init42()
is a valid
SimpleElementReferenceExpression. One or more
Expressions inside the paranthesis, separated by the
,
terminal, are also valid. Example:
init42(foo, bar + 27)
.
Please note:
The railroad diagrams themselves are generated from a textual grammar representation established and maintained with Xtext. If you suspect the diagrams shown here are lagging behind the actual implementation, look for files with the
.xtext
extension in the itemis CREATE source code distribution!
Please also note:
Not each and every construction that is syntactically allowed does make sense semantically. The statechart editor will flag such constructions as errors.
Figure "Statechart grammar" shows the statechart grammar. It makes use of the expressions grammar.
Statechart grammar
Figure "Expressions grammar" shows the expressions grammar. It is used by the statechart grammar.
Expressions grammar