Match implemented. Not tested yet.

This commit is contained in:
Andrey Breslav
2011-01-01 20:29:39 +03:00
parent a7b790cb13
commit f9fd2182ff
9 changed files with 484 additions and 328 deletions
+2 -1
View File
@@ -103,8 +103,9 @@ literalConstant
: StringWithTemplates
: NoEscapeString
: IntegerLiteral
: HexadecimalLiteral
: LongLiteral
: CharacterLiteral
: FloatLiteral
: "null"
;
+1
View File
@@ -62,6 +62,7 @@ match
out
ref
try
case
Soft:
wraps -- in a class header
+2 -7
View File
@@ -1,14 +1,13 @@
matchEntry
: attributes "case" pattern ("if" "(" expression ")")? "=>" expression // TODO: Consider other options than "=>"
: attributes "case" pattern ("if" "(" expression ")")? "=>" expression SEMI? // TODO: Consider other options than "=>"
;
pattern
: constantPattern // literal
: variablePattern // variable from the context
: SimpleName // variable from the context
: tuplePattern
: bindingPattern // we allow non-linear patterns
: decomposerPattern // labeled components are allowed
: arrowPattern
;
constantPattern
@@ -27,7 +26,3 @@ bindingPattern
decomposerPattern
: userType tuplePattern?
;
arrowPattern
: pattern "->" pattern
;