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
: classModifier* "class" SimpleName
("<" typeParameter{","} ">")?
("(" defaultConstructorParameter{","} ")")?
"wraps"?
("(" primaryConstructorParameter{","} ")")?
(":" delegationSpecifier{","})?
("where" typeConstraint{","})? // Syntax is questionable
classBody?
@@ -48,7 +49,7 @@ typeConstraint
// TODO: other constraints, maybe
;
defaultConstructorParameter
primaryConstructorParameter
: accessModifier? ("val" | "var")? parameter
;
+1 -1
View File
@@ -73,7 +73,7 @@ functionParameters
;
block
: "{" statements "}"
: "{" expression* "}"
;
functionBody
+13 -2
View File
@@ -2,5 +2,16 @@ SimpleName : /*java identifier*/;
FieldName : "$" SimpleName;
[helper] Digit : ["0".."9"];
IntegerLiteral : Digit+ "L"?
[helper] HaxDigit : Digit | ["A"-"F", "a"-"f"];
HexadecimaLiteral : "0x" HexDigit+;
[helper] HexDigit : Digit | ["A"-"F", "a"-"f"];
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
: "case" pattern "=>" expression // TODO: Consider other options than "=>"
: "case" pattern ("if" "(" expression ")")? "=>" expression // TODO: Consider other options than "=>"
;
pattern
: constantPattern // literal
: variablePattern // variable from the context
: tuplePattern
: bindingPattern
: bindingPattern // we allow non-linear patterns
: decomposerPattern // labeled components are allowed
;
+1 -1
View File
@@ -3,7 +3,7 @@ jetlFile
;
preamble
: empty
: // TODO: Imports?!
;
toplevelObject