Matches reorganized

This commit is contained in:
Andrey Breslav
2010-12-07 15:05:39 +03:00
parent 4690ea2bc7
commit a3d9d7af5c
5 changed files with 20 additions and 8 deletions
+3 -2
View File
@@ -13,7 +13,8 @@ internal class Example<X, T : Comparable<X>>(protected val x : Foo<X, T>, y : So
class class
: classModifier* "class" SimpleName : classModifier* "class" SimpleName
("<" typeParameter{","} ">")? ("<" typeParameter{","} ">")?
("(" defaultConstructorParameter{","} ")")? "wraps"?
("(" primaryConstructorParameter{","} ")")?
(":" delegationSpecifier{","})? (":" delegationSpecifier{","})?
("where" typeConstraint{","})? // Syntax is questionable ("where" typeConstraint{","})? // Syntax is questionable
classBody? classBody?
@@ -48,7 +49,7 @@ typeConstraint
// TODO: other constraints, maybe // TODO: other constraints, maybe
; ;
defaultConstructorParameter primaryConstructorParameter
: accessModifier? ("val" | "var")? parameter : accessModifier? ("val" | "var")? parameter
; ;
+1 -1
View File
@@ -73,7 +73,7 @@ functionParameters
; ;
block block
: "{" statements "}" : "{" expression* "}"
; ;
functionBody functionBody
+13 -2
View File
@@ -2,5 +2,16 @@ SimpleName : /*java identifier*/;
FieldName : "$" SimpleName; FieldName : "$" SimpleName;
[helper] Digit : ["0".."9"]; [helper] Digit : ["0".."9"];
IntegerLiteral : Digit+ "L"? IntegerLiteral : Digit+ "L"?
[helper] HaxDigit : Digit | ["A"-"F", "a"-"f"]; [helper] HexDigit : Digit | ["A"-"F", "a"-"f"];
HexadecimaLiteral : "0x" HexDigit+; HexadecimalLiteral : "0x" HexDigit+;
StringWithPatterns : /*single-quoted string, $ can be escaped*/;
NoEscapeString : /* @-prefixed string, maybe allow putting a bar for indentation correction */;
/*
val foo = @"
|Blah-blah-blah
foobar
barfoo
"
*/
+2 -2
View File
@@ -3,14 +3,14 @@ match
; ;
matchEntry matchEntry
: "case" pattern "=>" expression // TODO: Consider other options than "=>" : "case" pattern ("if" "(" expression ")")? "=>" expression // TODO: Consider other options than "=>"
; ;
pattern pattern
: constantPattern // literal : constantPattern // literal
: variablePattern // variable from the context : variablePattern // variable from the context
: tuplePattern : tuplePattern
: bindingPattern : bindingPattern // we allow non-linear patterns
: decomposerPattern // labeled components are allowed : decomposerPattern // labeled components are allowed
; ;
+1 -1
View File
@@ -3,7 +3,7 @@ jetlFile
; ;
preamble preamble
: empty : // TODO: Imports?!
; ;
toplevelObject toplevelObject