summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2009-06-30 20:59:49 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2009-06-30 20:59:49 +0000
commitd6519af64cab257fd45d12b818b2117e9c0f5440 (patch)
tree25fcaf1497bdb439caa791bc74fd5de40dda3c7c /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parenta784a5846bbddea5321aa742041dbf8b2f87cbae (diff)
downloadscala-d6519af64cab257fd45d12b818b2117e9c0f5440.tar.gz
scala-d6519af64cab257fd45d12b818b2117e9c0f5440.tar.bz2
scala-d6519af64cab257fd45d12b818b2117e9c0f5440.zip
minor cleanups for named args
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/parser/Parsers.scala35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 9d6a8af329..5b22914b23 100755
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -471,6 +471,16 @@ self =>
}
}
+ /** part {`,' part} */
+ def commaSeparated(part: () => Tree): List[Tree] = {
+ val ts = new ListBuffer[Tree] += part()
+ while (in.token == COMMA) {
+ in.nextToken()
+ ts += part()
+ }
+ ts.toList
+ }
+
/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
/** modes for infix types */
@@ -690,7 +700,7 @@ self =>
/** Types ::= Type {`,' Type}
*/
def types(isPattern: Boolean, isTypeApply: Boolean, isFuncArg: Boolean): List[Tree] =
- exprs(() => argType(isPattern, isTypeApply, isFuncArg))
+ commaSeparated(() => argType(isPattern, isTypeApply, isFuncArg))
/** Type ::= InfixType `=>' Type
* | `(' [`=>' Type] `)' `=>' Type
@@ -906,17 +916,6 @@ self =>
expr()
}
- /** Exprs ::= Expr {`,' Expr}
- */
- def exprs(part: () => Tree = expr _): List[Tree] = {
- val ts = new ListBuffer[Tree] += part()
- while (in.token == COMMA) {
- in.nextToken()
- ts += part()
- }
- ts.toList
- }
-
def condExpr(): Tree = {
if (in.token == LPAREN) {
in.nextToken()
@@ -1174,7 +1173,7 @@ self =>
id
case LPAREN =>
atPos(in.skipToken()) {
- val ts = if (in.token == RPAREN) List() else exprs()
+ val ts = if (in.token == RPAREN) List() else commaSeparated(expr _)
accept(RPAREN)
Parens(ts)
}
@@ -1237,11 +1236,11 @@ self =>
* | [nl] BlockExpr
*/
def argumentExprs(): List[Tree] = {
- def args(): List[Tree] = exprs(() => {
+ def args(): List[Tree] = commaSeparated(() => {
val maybeNamed = isIdent
expr() match {
case a @ Assign(id, rhs) if maybeNamed =>
- atPos(a.pos) { new AssignOrNamedArg(id, rhs) }
+ atPos(a.pos) { AssignOrNamedArg(id, rhs) }
case e => e
}
})
@@ -1255,7 +1254,7 @@ self =>
rhs match {
case Ident(`pname1`) | Typed(Ident(`pname1`), _) =>
placeholderParams = vd :: placeholderParams
- atPos(arg.pos) { new AssignOrNamedArg(Ident(aname), Ident(pname1)) }
+ atPos(arg.pos) { AssignOrNamedArg(Ident(aname), Ident(pname1)) }
case _ => arg
}
case _ => arg
@@ -1359,7 +1358,7 @@ self =>
* SeqPatterns ::= SeqPattern { `,' SeqPattern }
*/
def patterns(seqOK: Boolean): List[Tree] =
- exprs(() => pattern(seqOK))
+ commaSeparated(() => pattern(seqOK))
/** Pattern ::= Pattern1 { `|' Pattern1 }
* SeqPattern ::= SeqPattern1 { `|' SeqPattern1 }
@@ -1828,7 +1827,7 @@ self =>
*/
def importClause(): List[Tree] = {
accept(IMPORT)
- exprs(() => importExpr())
+ commaSeparated(() => importExpr())
}
/** ImportExpr ::= StableId `.' (Id | `_' | ImportSelectors)