Table of Contents
Production
While left-hand sides of rules are specified by queries, right-hand sides consist of production statements which have a special syntax and are mostly defined by operator overloading. At the beginning of the outermost sequence of production statements (i. e., at the beginning of a right-hand side, of production statements within imperative code, or of an instantiation rule), the method producer$begin is invoked
on the current producer. It is a compile-time error if this method does not exist. The result of the invocation is taken as new current producer. At the end of the outermost sequence of production statements, the method producer$end is invoked on the current producer. Again, it is a compile-time error if this
method does not exist.
Within production statements, fields and methods declared or inherited by the type of the current producer can be referred to by their simple name. For instance fields and methods, the current producer is used as the implicit target reference similar to the implicit this in bodies of instance methods. However, these fields or methods do not shadow members with the same name in enclosing scopes, i. e., the latter have higher priority.
Node
Node expressions are used to specify nodes within production statements. Every non-void expression is considered as a node expression. The two most common cases are:
- Node creation, from either the constructor or method
- Reference variables created in either the production, or passed by the query
Note: void expressions are simply evaluated and has no further influence on the execution of the
production statements. (e.g. ==> Node println(“xx”) Node; create two Nodes).
Operators
Each node expression is prefixed by an operator. Both together constitute a
single production statement which passes the result of the node expression to
the current producer. In the simplest case, node expressions are prefixed by
whitespace only, which is an operator.
Sub-tree
Like for queries, the symbols [ and ] are used to enclose sub-trees. These
symbols are not mapped to operator methods, but to special producer methods producer$push, producer$pop
In RGG, the sub trees created in a production statement are connected on the first node to the left with a Branch edge. Thus, N1 [N2 N3] connect the sub-tree produced by N2 N3 to N1 with a branch edge.
Separator
A specific producer method producer$separate can be used to create parts unconnected from the right-hand side. The use symbol in XL is ,.
Control flow
Almost any control flow statement is also allowed as a production statement, namely the compound
control flow statements if, for, do, while, switch and synchronized and the
simple control flow statements break, continue and throw.
The control flow statements use parenthesis ( and ) as block delimiters (unlike in java where curly brackets are used).
Code block
A production statement can include conventional imperative code blocks. They are delimited by curly brackets { and }. These blocks do not declare their own scope, but instead use the scope of the production statement. Thus, variable declared in the production can be used in the code block.
Function
It is possible to declare a function that can represent a production element. The function receive implicitly the current producer object and run its declared production rule. The first argument of the function must be of the same type of the implicitly given producer. The method must return void.
Stand-Alone
Because the only requirement to start a production statement is that the caller is able to create a Producer (which can be any type of Object in the java sense), any object can start a production. Within rules, after the query the query graph is responsible for creating the producer. In the case of RGG, it creates a RGGProducer.
Within normal statement blocks (in a java block), any Object can serve to create the “Producer”, there are not interface or class to extend. It only need to implements the required methods, which are retrieved at compile time.
Extent index
When a node is created in a production statement, it is added by default on the same extent index as the most left Node from the query.
