From a3d9d7af5cd940ac3a62bfffc7559dd31c0eb655 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 7 Dec 2010 15:05:39 +0300 Subject: [PATCH] Matches reorganized --- grammar/src/class.grm | 5 +++-- grammar/src/class_members.grm | 2 +- grammar/src/lexical.grm | 15 +++++++++++++-- grammar/src/match.grm | 4 ++-- grammar/src/toplevel.grm | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/grammar/src/class.grm b/grammar/src/class.grm index 3ffb4e870c4..c7d533f6925 100644 --- a/grammar/src/class.grm +++ b/grammar/src/class.grm @@ -13,7 +13,8 @@ internal class Example>(protected val x : Foo, 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 ; diff --git a/grammar/src/class_members.grm b/grammar/src/class_members.grm index 6aa706f2ed7..2fd7ae9de5d 100644 --- a/grammar/src/class_members.grm +++ b/grammar/src/class_members.grm @@ -73,7 +73,7 @@ functionParameters ; block - : "{" statements "}" + : "{" expression* "}" ; functionBody diff --git a/grammar/src/lexical.grm b/grammar/src/lexical.grm index 0b11e17837d..2368e558c62 100644 --- a/grammar/src/lexical.grm +++ b/grammar/src/lexical.grm @@ -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+; \ No newline at end of file +[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 +" +*/ \ No newline at end of file diff --git a/grammar/src/match.grm b/grammar/src/match.grm index 9a448fed2e1..2b88ee7fc4c 100644 --- a/grammar/src/match.grm +++ b/grammar/src/match.grm @@ -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 ; diff --git a/grammar/src/toplevel.grm b/grammar/src/toplevel.grm index 82fb18100bb..e981319415c 100644 --- a/grammar/src/toplevel.grm +++ b/grammar/src/toplevel.grm @@ -3,7 +3,7 @@ jetlFile ; preamble - : empty + : // TODO: Imports?! ; toplevelObject