Removing grammar/parsing support for complext patterns

#KT-2359 In progress
This commit is contained in:
Andrey Breslav
2012-09-05 12:49:04 +04:00
parent a7f62a7d6e
commit 10d453ce6a
20 changed files with 515 additions and 1664 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ longTemplate
;
isRHS
: pattern
: type
;
declaration
+3 -40
View File
@@ -10,51 +10,14 @@ when
"}"
;
// TODO : consider empty after ->
whenEntry
// TODO : consider empty after =>
: whenCondition{","} "=>" expression SEMI
: "else" "=>" expression SEMI
: whenCondition{","} "->" expression SEMI
: "else" "->" expression SEMI
;
whenCondition
: expression
: ("in" | "!in") expression
: ("is" | "!is") isRHS
;
pattern
: annotations pattern
: type // '[a] T' is a type-pattern 'T' with an attribute '[a]', not a type-pattern '[a] T'
// this makes sense because is-check may be different for a type with attributes
: tuplePattern
: decomposerPattern
: constantPattern
: bindingPattern
: "*" // wildcard pattern
;
decomposerPattern
: type
// TODO : typeArguments will be consumed by the expression
: elvisExpression typeArguments? tuplePattern
;
constantPattern
: literalConstant
;
tuplePattern
: "(" (((SimpleName "=")? pattern){","})? ")"
;
bindingPattern
: "val" SimpleName binding?
;
binding
: "is" pattern
: "!is" pattern
: "in" expression
: "!in" expression
: ":" type
;