/* (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.*; /** * This grammar defines a typical standard set of operations for * expressions. This is a subset of Java for binary expressions * like <<, >>, >>>, &, ^ and | * * There are also other kinds of expressions defined in the * grammars mentioned below. These expression definitions can savely be * composed if desired. * * 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 BitExpressions extends ExpressionsBasis { /*=================================================================*/ interface ShiftExpression = left:Expression shiftOp:"" right:Expression; /* The priorities (160, 120 and 110) are compatible with the priorities * of the other infix operations e.g. in CommonExpressions * leading to Java' like priorization. */ /*=================================================================*/ /* Due to possible scanner clashes with "List>" we split the tokens: */ splittoken ">>", ">>>"; LeftShiftExpression implements Expression <160>, ShiftExpression = left:Expression shiftOp:"<<" right:Expression; RightShiftExpression implements Expression <160>, ShiftExpression = left:Expression shiftOp:">>" right:Expression; LogicalRightShiftExpression implements Expression <160>, ShiftExpression = left:Expression shiftOp:">>>" right:Expression; /*=================================================================*/ interface BinaryExpression = left:Expression operator:"" right:Expression; BinaryAndExpression implements BinaryExpression, Expression <120> = left:Expression operator:"&" right:Expression; BinaryXorExpression implements BinaryExpression, Expression <110> = left:Expression operator:"^" right:Expression; BinaryOrOpExpression implements BinaryExpression, Expression <100> = left:Expression operator:"|" right:Expression; }