Function types and literals
This commit is contained in:
@@ -26,6 +26,7 @@ val f1 = {(t : T) : X => something(t)}
|
||||
fun f1(t : T) : X = something(t)
|
||||
|
||||
val f1 = {(t : T) => something(t)}
|
||||
val f1 = {(T) : X => something(it)}
|
||||
val f1 = {t => something(t)}
|
||||
val f1 = {something(it)}
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ tupleLiteral
|
||||
;
|
||||
|
||||
functionLiteral
|
||||
: "{" (parameter | SimpleName)* "=>" expression "}"
|
||||
: "{" SimpleName "=>" expression "}"
|
||||
: "{" functionTypeContents "=>" expression "}"
|
||||
: "{" "(" parameter{","} ")" "=>" expression "}"
|
||||
;
|
||||
|
||||
constructorInvocation
|
||||
|
||||
+15
-3
@@ -15,15 +15,27 @@ type
|
||||
;
|
||||
|
||||
userType
|
||||
: name ("<" type{","} ">")?
|
||||
: name ("<" (projectionSpecifier type){","} ">")?
|
||||
;
|
||||
|
||||
projectionSpecifier
|
||||
: "in"
|
||||
: "out"
|
||||
: empty
|
||||
;
|
||||
|
||||
functionType
|
||||
: "{" type{","} "=>" type "}"
|
||||
: "{" functionTypeContents "}"
|
||||
;
|
||||
|
||||
functionTypeContents
|
||||
: "(" (parameter | type){","} ")" ":" type
|
||||
;
|
||||
|
||||
tupleType
|
||||
: "(" type"{","} ")"
|
||||
: "(" type{","} ")"
|
||||
;
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user