/* (c) https://github.com/MontiCore/monticore */ package de.monticore.expressions; /* This is a MontiCore stable grammar. * Adaptations -- if any -- are conservative. */ import de.monticore.expressions.ExpressionsBasis; /** * This grammar extends the available expressions with * special operations for streams as initially defined by * Broy/Stoelen in [BS01] using the syntax from * Ringert/Rumpe [RR11] and * Buerger, Kausch, Raco, Ringert, Rumpe, Stueber, Wiartalla [BKR+20] * (see https://www.se-rwth.de/publications/) * * Stream expressions are partly * 1) extending the Expression syntax by grammatical operations (see below), * 2) are provided as library of available Stream operations, and * 3) are based on the type constructor Stream (defined in Types) * * The language developer may choose the subset of expressions * of interest and combine these with the appropriate typing infrastructure * * This modularity of expressions and associated types greatly eases * the reuse of type structures in languages similar to Java * * This grammar is part of a hierarchy of expressions, which can be found * under * https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/ * src/main/grammars/de/monticore/expressions/Expressions.md * */ component grammar StreamExpressions extends CommonExpressions { /* ------ Special Syntax for Functions on Streams ---------------- */ /* * Empty Stream constant */ EmptyStreamExpression implements Expression = "<>"; /* * Append first element * a:b:c is equal to a:(b:c), hence * a:b^^c is equal to a:(b^^c) * a+b:c is equal to (a+b):c, and * a <= b:c is equal to a <= (b:c), hence the priority 154, 156 */ AppendStreamExpression implements Expression <154>, InfixExpression = left:Expression operator:":" right:Expression; /* * Concatenation of streams * a^^b^^c is equal to a^^(b^^c), hence */ ConcatStreamExpression implements Expression <156>, InfixExpression = left:Expression operator:"^^" right:Expression; /* * Length of stream */ LengthStreamExpression implements Expression <185> = "#" Expression; }