diff --git a/grammar/src/expressions.grm b/grammar/src/expressions.grm index 9e5fad9a351..6b9c12ed45e 100644 --- a/grammar/src/expressions.grm +++ b/grammar/src/expressions.grm @@ -1,18 +1,35 @@ expression + : "(" expression ")" // see tupleLiteral : "new" constructorInvocation : literalConstant : functionLiteral : tupleLiteral + : listLiteral + : mapLiteral : "null" : binOpExpression : unOpExpression - : name functionParameters? // ambiguity here + : name functionParameters? // TODO: ambiguity here : FieldName : if -// list comprehension +// TODO: list comprehension : jump ; +binaryOperation + : "+" : "-" : "*" : "/" + : "|" : "||" : "&" : "&&" : "^" // Maybe we can drop "^" + : "<" : ">" : ">=" : "<=" + : "==" : "===" + : "in" + : "is" : "isnot" + ; + +unaryOperation + : "-" : "+" + : "!" + ; + jump : "throw" expression : "return" expression @@ -21,8 +38,9 @@ jump // yield ? ; -tupleLiteral - : "(" expression{","} ")" +tupleLiteral // No, (a) is not a tuple + : "(" ")" + : "(" expression ("," expression)+ ")" ; functionLiteral @@ -34,3 +52,16 @@ functionLiteral constructorInvocation : userType "(" expression{","} ")" ; + +listLiteral + : "[" expression{","} "]" + ; + +mapLiteral + : "[" mapEntryLiteral ("," mapEntryLiteral)* "]" + : "[" ":" "]" + ; + +mapEntryLiteral + : expression ":" expression + ; \ No newline at end of file