User Tools

Site Tools


01_user_documentation:07_rgg_xl:02_xl:03_query:05_query_expression

Query expression

A query can be used as an expression if it is enclosed in asterisked parentheses (* and *). Theses symbols are also used to declare context in a query but the concept is different. A query expression enables to execute the query in an imperative context (e.g. in a java block). Thus, the query can be used combined with other imperative statements (e.g. methods, aggregators, …). The query expression is a Node generator and can be used as such.

Query expressions finds all matches of the pattern and yields the currently bound value of the right-most non-bracketed node pattern.

The model graph of such expression is defined implicitly based on the first enclosing declaration which has an annotation of the type @UseModel. The annotation takes an argument to specify a concrete class to use as compile time model.

For instance:

void run() { // java block
  (* ^ (>)* Node *); // this query expression is applied by the model graph of the enclosing method call
}

If we want to specify the current graph explicitly, it has to be prepended in front of the query as in

 graph.(* ^ (>)* Node *) // this query expression is applied by graph

Then the current graph is the result of the prepended expression. The type of the expression has to be a subtype of Graph, and it has to have or inherit an annotation of type @HasModel whose single element specifies the corresponding compile-time model.

01_user_documentation/07_rgg_xl/02_xl/03_query/05_query_expression.txt · Last modified: 2025/09/04 12:07 by gaetan