Expressions

This commit is contained in:
Andrey Breslav
2010-11-15 17:28:56 +03:00
parent 050f7c661b
commit 58eacb1e00
+35 -4
View File
@@ -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
;