diff options
author | Enno Runne <enno.runne@baymarkets.com> | 2017-02-14 21:16:47 +0100 |
---|---|---|
committer | Enno Runne <enno.runne@baymarkets.com> | 2017-02-14 21:16:47 +0100 |
commit | 81cda70db72046901e8ca5f8c958224cafdf1bf4 (patch) | |
tree | 71c00946da2050fdafa2349e6bc3891237b0b0de /compiler/src/dotty/tools/dotc/parsing/Parsers.scala | |
parent | 606e36be88c47cd3f2e8856d6bd6b95aed7aa191 (diff) | |
download | dotty-81cda70db72046901e8ca5f8c958224cafdf1bf4.tar.gz dotty-81cda70db72046901e8ca5f8c958224cafdf1bf4.tar.bz2 dotty-81cda70db72046901e8ca5f8c958224cafdf1bf4.zip |
Change '... expected but found ...' to Message
Diffstat (limited to 'compiler/src/dotty/tools/dotc/parsing/Parsers.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 9f4cdbd35..45ae842b6 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -110,7 +110,8 @@ object Parsers { */ def syntaxError(msg: => Message, offset: Int = in.offset): Unit = if (offset > lastErrorOffset) { - syntaxError(msg, Position(offset)) + val length = if (in.name != null) in.name.show.length else 0 + syntaxError(msg, Position(offset, offset + length)) lastErrorOffset = in.offset } @@ -249,11 +250,6 @@ object Parsers { lastErrorOffset = in.offset } // DEBUG - private def expectedMsg(token: Int): String = - expectedMessage(showToken(token)) - private def expectedMessage(what: String): String = - s"$what expected but ${showToken(in.token)} found" - /** Consume one token of the specified type, or * signal an error if it is not there. * @@ -262,7 +258,7 @@ object Parsers { def accept(token: Int): Int = { val offset = in.offset if (in.token != token) { - syntaxErrorOrIncomplete(expectedMsg(token)) + syntaxErrorOrIncomplete(ExpectedTokenButFound(token, in.token, in.name)) } if (in.token == token) in.nextToken() offset @@ -474,7 +470,7 @@ object Parsers { in.nextToken() name } else { - syntaxErrorOrIncomplete(expectedMsg(IDENTIFIER)) + syntaxErrorOrIncomplete(ExpectedTokenButFound(IDENTIFIER, in.token, in.name)) nme.ERROR } @@ -1055,7 +1051,7 @@ object Parsers { case Block(Nil, EmptyTree) => assert(handlerStart != -1) syntaxError( - new EmptyCatchBlock(body), + EmptyCatchBlock(body), Position(handlerStart, endOffset(handler)) ) case _ => |