Skip to content

Allow connection endpoints for list nonterminals

Current situation

Example: grammar.relast:

Root ::= A B*;
A ::= <Id> <Value> ;
B ::= <Id> <Value> ;

Currently only the following is possible in example.connect:

receive tree Root.A ;

And as a workaround to also be able to receive B*, one has to introduce WrapperB:

Root ::= A WrapperB ;
WrapperB ::= B* ;
A ::= <Id> <Value> ;
B ::= <Id> <Value> ;

and

receive tree Root.WrapperB ;

With this feature

With this extensions, it should also be possible to update lists in example.connect:

receive tree Root.B ;

Potentially, a new choice is required to either set or append to the list, e.g. in example.connect,

receive tree with set Root.B ;
// or
receive tree with add Root.B ;

Possible Scenarios

  • Receiving a message containing multiple elements (of the same type) which are transformed into a JastAddList and
    • L1 then set as the new list, or
    • L2 then appended to the existing list
  • The received message only contains one element and
    • S1 there are multiple connect statements called where each topic is associated with a fixed list position, and the received element is set for this position, or
    • S2 there is one connect statement using a wildcard (# for mqtt) and each new topic is associated with a new fixed list position, and the received element is set for this position, or
    • S3 it will be added to the list
  • RS: For S1, it is unclear, whether "empty" nodes are added upon connect, or in front of a node if previous nodes do not yet have received an initial value, or not at all
  • RS: For S1 and S2, RagConnect could add a new token to the nonterminal of the list (B in the example) to represent the origin "topic (part)"

Examples for receiving lists

In both cases, connecting is as follows:

root.connectB("node/listB");

Assuming an empty list at the beginning, receiving different nodes (only Id shown) results in the following behaviour:

Approach Initial After receiving [1] After receiving [2,3] After receiving [4]
L1 [] [1] [2, 3] [4]
L2 [] [1] [1, 2, 3] [1, 2, 3, 4]

Example for receiving single values

S1:

root.connectB("listB/first");
root.connectB("listB/second");
root.connectB("listB/third");
root.connectB("listB/fourth");

S2:

root.connectB("listB/#");

S3:

root.connectB("listB");

Assuming an empty list at the beginning, receiving nodes (Id and Value shown as Id:Value) via different topics results in the following behaviour. Note, that for S3 the topic is always listB instead of the listed one.

Approach Initial 1:1 at listB/first 4:0 at listB/fourth 2:2 at listB/first 3:3 at listB/third
S1 [] [1:1] [1:1, <empty>, <empty>, 4:0] [2:2, <empty>, <empty>, 4:0] [2:2, <empty>, 3:3, 4:0]
S2 [] [1:1] [1:1, 4:0] [2:2, 4:0] [2:2, 4:0, 3:3]
S1 [] [1:1] [1:1, 4:0] [1:1, 4:0, 2:2] [1:1, 4:0, 2:2, 3:3]
Edited by René Schöne