summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2003-05-16 14:16:56 +0000
committerburaq <buraq@epfl.ch>2003-05-16 14:16:56 +0000
commit89cec93a5dc95970500aa0f649611d5a9a9e67a9 (patch)
treea67b78477fbe5c81a89f70395270b1501cae5c47 /sources
parentbdc7125ab59e71ace676a2e2304783ea1b04edee (diff)
downloadscala-89cec93a5dc95970500aa0f649611d5a9a9e67a9.tar.gz
scala-89cec93a5dc95970500aa0f649611d5a9a9e67a9.tar.bz2
scala-89cec93a5dc95970500aa0f649611d5a9a9e67a9.zip
fixed recognition of subsequences (like in List...
fixed recognition of subsequences (like in List( 1,2,(1,2)* ), especially empty subsequences (like this one (,,||,,,|,|,,|,,) for example)
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/ast/parser/Parser.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/sources/scalac/ast/parser/Parser.java b/sources/scalac/ast/parser/Parser.java
index a6831ea6f8..1073f8222f 100644
--- a/sources/scalac/ast/parser/Parser.java
+++ b/sources/scalac/ast/parser/Parser.java
@@ -1024,6 +1024,7 @@ public class Parser implements Tokens {
{
if ( s.name == STAR ) /* p* becomes z@( |(p,z)) */
{
+ s.nextToken();
Name zname= fresh();
Tree zvar = make.Ident( s.pos, zname );
@@ -1037,6 +1038,7 @@ public class Parser implements Tokens {
}
else if ( s.name == PLUS ) /* p+ becomes z@(p,(z| )) */
{
+ s.nextToken();
Name zname= fresh();
Tree zvar = make.Ident( s.pos, zname );
@@ -1050,6 +1052,7 @@ public class Parser implements Tokens {
}
else if ( s.name == OPT ) /* p? becomes (p| ) */
{
+ s.nextToken();
return make.Alternative( s.pos, new Tree[] {
top,
make.Subsequence( s.pos, Tree.EMPTY_ARRAY )});
@@ -1070,17 +1073,19 @@ public class Parser implements Tokens {
* | literal
* | null
* | StableId {ArgumentPatterns}
- * | `(' Pattern `)'
+ * | `(' Patterns `)'
* | ((nothing))
*/
Tree simplePattern() {
switch (s.token) {
+ case COMMA:
+ return make.Subsequence( s.pos, Tree.EMPTY_ARRAY ); // ((nothing))
case IDENTIFIER:
if( s.name == BAR )
{
return make.Subsequence( s.pos, Tree.EMPTY_ARRAY ); // ((nothing))
}
-
+ // else fall through to case THIS
case THIS:
Tree t = stableId();
switch( t ) {
@@ -1110,8 +1115,14 @@ public class Parser implements Tokens {
case NULL:
return literal(true);
case LPAREN:
+ int p = s.pos;
s.nextToken();
- Tree t = pattern();
+ Tree[] ts = patterns();
+ Tree t;
+ if( ts.length == 1 )
+ t = ts[ 0 ];
+ else
+ t = make.Subsequence( s.pos, ts );
accept(RPAREN);
return t;
default: