Expressions
This commit is contained in:
@@ -1,18 +1,35 @@
|
|||||||
expression
|
expression
|
||||||
|
: "(" expression ")" // see tupleLiteral
|
||||||
: "new" constructorInvocation
|
: "new" constructorInvocation
|
||||||
: literalConstant
|
: literalConstant
|
||||||
: functionLiteral
|
: functionLiteral
|
||||||
: tupleLiteral
|
: tupleLiteral
|
||||||
|
: listLiteral
|
||||||
|
: mapLiteral
|
||||||
: "null"
|
: "null"
|
||||||
: binOpExpression
|
: binOpExpression
|
||||||
: unOpExpression
|
: unOpExpression
|
||||||
: name functionParameters? // ambiguity here
|
: name functionParameters? // TODO: ambiguity here
|
||||||
: FieldName
|
: FieldName
|
||||||
: if
|
: if
|
||||||
// list comprehension
|
// TODO: list comprehension
|
||||||
: jump
|
: jump
|
||||||
;
|
;
|
||||||
|
|
||||||
|
binaryOperation
|
||||||
|
: "+" : "-" : "*" : "/"
|
||||||
|
: "|" : "||" : "&" : "&&" : "^" // Maybe we can drop "^"
|
||||||
|
: "<" : ">" : ">=" : "<="
|
||||||
|
: "==" : "==="
|
||||||
|
: "in"
|
||||||
|
: "is" : "isnot"
|
||||||
|
;
|
||||||
|
|
||||||
|
unaryOperation
|
||||||
|
: "-" : "+"
|
||||||
|
: "!"
|
||||||
|
;
|
||||||
|
|
||||||
jump
|
jump
|
||||||
: "throw" expression
|
: "throw" expression
|
||||||
: "return" expression
|
: "return" expression
|
||||||
@@ -21,8 +38,9 @@ jump
|
|||||||
// yield ?
|
// yield ?
|
||||||
;
|
;
|
||||||
|
|
||||||
tupleLiteral
|
tupleLiteral // No, (a) is not a tuple
|
||||||
: "(" expression{","} ")"
|
: "(" ")"
|
||||||
|
: "(" expression ("," expression)+ ")"
|
||||||
;
|
;
|
||||||
|
|
||||||
functionLiteral
|
functionLiteral
|
||||||
@@ -34,3 +52,16 @@ functionLiteral
|
|||||||
constructorInvocation
|
constructorInvocation
|
||||||
: userType "(" expression{","} ")"
|
: userType "(" expression{","} ")"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
listLiteral
|
||||||
|
: "[" expression{","} "]"
|
||||||
|
;
|
||||||
|
|
||||||
|
mapLiteral
|
||||||
|
: "[" mapEntryLiteral ("," mapEntryLiteral)* "]"
|
||||||
|
: "[" ":" "]"
|
||||||
|
;
|
||||||
|
|
||||||
|
mapEntryLiteral
|
||||||
|
: expression ":" expression
|
||||||
|
;
|
||||||
Reference in New Issue
Block a user