summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-04-04 16:30:11 +0000
committerMartin Odersky <odersky@gmail.com>2007-04-04 16:30:11 +0000
commit51d9edec14b5c56f6fc4d283fa27fb7c7d782249 (patch)
tree2ba1165c504cac44b3b1545b8b1274ccf2b05ff9 /src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
parent7f3c7c392467b128af32d416edf521f468caf34c (diff)
downloadscala-51d9edec14b5c56f6fc4d283fa27fb7c7d782249.tar.gz
scala-51d9edec14b5c56f6fc4d283fa27fb7c7d782249.tar.bz2
scala-51d9edec14b5c56f6fc4d283fa27fb7c7d782249.zip
explicit supercalls + new style for syntax + ba...
explicit supercalls + new style for syntax + backquoted ids in patterns
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Scanners.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala56
1 files changed, 35 insertions, 21 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 080c83f49c..8eb785b38e 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -37,12 +37,24 @@ trait Scanners requires SyntaxAnalyzer {
/** the base of a number */
var base: int = 0
- def copyFrom(td: TokenData) = {
+ /** further lookahead tokens after this one */
+ var following: TokenData = null
+
+ def copyFrom(td: TokenData) {
this.token = td.token
this.pos = td.pos
this.lastPos = td.lastPos
this.name = td.name
this.base = td.base
+ td.token = EMPTY
+ }
+
+ def pushFrom(td: TokenData) {
+ if (token != EMPTY) {
+ following = new TokenData
+ following copyFrom this
+ }
+ this copyFrom td
}
}
@@ -145,42 +157,45 @@ trait Scanners requires SyntaxAnalyzer {
if (next.token == EMPTY) {
fetchToken()
} else {
- this.copyFrom(next)
- next.token = EMPTY
+ this copyFrom next
+ if (next.following != null) {
+ next copyFrom next.following
+ next.following = null
+ }
}
if (token == CASE) {
- prev.copyFrom(this)
+ prev copyFrom this
fetchToken()
if (token == CLASS) {
+ this copyFrom prev
token = CASECLASS
- lastPos = prev.lastPos
} else if (token == OBJECT) {
+ this copyFrom prev
token = CASEOBJECT
- lastPos = prev.lastPos
} else {
- next.copyFrom(this)
- this.copyFrom(prev)
+ next pushFrom this
+ this copyFrom prev
}
+ } else if (token == SUPER && next.token == EMPTY) {
+ prev copyFrom this
+ fetchToken()
+ val isSuperCall = token == LPAREN
+ next pushFrom this
+ this copyFrom prev
+ if (isSuperCall) token = SUPERCALL
} else if (token == SEMI) {
- prev.copyFrom(this)
+ prev copyFrom this
fetchToken()
if (token != ELSE) {
- next.copyFrom(this)
- this.copyFrom(prev)
+ next pushFrom this
+ this copyFrom prev
}
- } else if (token == IDENTIFIER && name == nme.MIXINkw) { //todo: remove eventually
- prev.copyFrom(this)
- fetchToken()
- if (token == CLASS)
- unit.warning(prev.pos, "`mixin' is no longer a reserved word; you should use `trait' instead of `mixin class'");
- next.copyFrom(this)
- this.copyFrom(prev)
}
if (afterLineEnd() && inLastOfStat(lastToken) && inFirstOfStat(token) &&
(sepRegions.isEmpty || sepRegions.head == RBRACE)) {
- next.copyFrom(this)
+ next pushFrom this
pos = in.lineStartPos
if (settings.migrate.value) newNewLine = lastToken != RBRACE && token != EOF;
token = if (in.lastBlankLinePos > lastPos) NEWLINES else NEWLINE
@@ -273,7 +288,7 @@ trait Scanners requires SyntaxAnalyzer {
return
case '`' =>
in.next
- getStringLit('`', IDENTIFIER)
+ getStringLit('`', BACKQUOTED_IDENT)
return
case '\"' =>
in.next
@@ -569,7 +584,6 @@ trait Scanners requires SyntaxAnalyzer {
}
private def getStringLit(delimiter: char, litType: int): unit = {
- assert((litType==STRINGLIT) || (litType==IDENTIFIER))
while (in.ch != delimiter && (in.isUnicode || in.ch != CR && in.ch != LF && in.ch != SU)) {
getlitch()
}