summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2014-07-19 19:26:39 -0700
committerSom Snytt <som.snytt@gmail.com>2014-07-19 19:26:39 -0700
commitccbb84bb87a9dd828fa3aca1a1a14487e327ec5b (patch)
treec2aeb6fe8762fe87c73503bf579ff5d244d76a56
parentb4f506749189b337bd25633d521b6b917108ee15 (diff)
downloadscala-ccbb84bb87a9dd828fa3aca1a1a14487e327ec5b.tar.gz
scala-ccbb84bb87a9dd828fa3aca1a1a14487e327ec5b.tar.bz2
scala-ccbb84bb87a9dd828fa3aca1a1a14487e327ec5b.zip
SI-6476 Unitize procedures, readability
Strictly trivial updates for readability. I used to prefer procedure syntax, but since it was scheduled for removal, I can't scan a def without an equals sign.
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala36
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala16
2 files changed, 24 insertions, 28 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 90bc53721d..9350a39cbe 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -204,13 +204,11 @@ self =>
override def newScanner() = new UnitScanner(unit, patches)
- override def warning(offset: Offset, msg: String) {
+ override def warning(offset: Offset, msg: String): Unit =
reporter.warning(o2p(offset), msg)
- }
- override def deprecationWarning(offset: Offset, msg: String) {
+ override def deprecationWarning(offset: Offset, msg: String): Unit =
currentRun.reporting.deprecationWarning(o2p(offset), msg)
- }
private var smartParsing = false
@inline private def withSmartParsing[T](body: => T): T = {
@@ -226,12 +224,12 @@ self =>
for ((offset, msg) <- syntaxErrors)
reporter.error(o2p(offset), msg)
- override def syntaxError(offset: Offset, msg: String) {
+ override def syntaxError(offset: Offset, msg: String): Unit = {
if (smartParsing) syntaxErrors += ((offset, msg))
else reporter.error(o2p(offset), msg)
}
- override def incompleteInputError(msg: String) {
+ override def incompleteInputError(msg: String): Unit = {
val offset = source.content.length - 1
if (smartParsing) syntaxErrors += ((offset, msg))
else currentRun.reporting.incompleteInputError(o2p(offset), msg)
@@ -544,27 +542,25 @@ self =>
}
def warning(offset: Offset, msg: String): Unit
def incompleteInputError(msg: String): Unit
- private def syntaxError(pos: Position, msg: String, skipIt: Boolean) {
- syntaxError(pos pointOrElse in.offset, msg, skipIt)
- }
def syntaxError(offset: Offset, msg: String): Unit
- def syntaxError(msg: String, skipIt: Boolean) {
+
+ private def syntaxError(pos: Position, msg: String, skipIt: Boolean): Unit =
+ syntaxError(pos pointOrElse in.offset, msg, skipIt)
+ def syntaxError(msg: String, skipIt: Boolean): Unit =
syntaxError(in.offset, msg, skipIt)
- }
- def syntaxError(offset: Offset, msg: String, skipIt: Boolean) {
+ def syntaxError(offset: Offset, msg: String, skipIt: Boolean): Unit = {
if (offset > lastErrorOffset) {
syntaxError(offset, msg)
- // no more errors on this token.
- lastErrorOffset = in.offset
+ lastErrorOffset = in.offset // no more errors on this token.
}
if (skipIt)
skip(UNDEF)
}
- def warning(msg: String) { warning(in.offset, msg) }
+ def warning(msg: String): Unit = warning(in.offset, msg)
- def syntaxErrorOrIncomplete(msg: String, skipIt: Boolean) {
+ def syntaxErrorOrIncomplete(msg: String, skipIt: Boolean): Unit = {
if (in.token == EOF)
incompleteInputError(msg)
else
@@ -1233,15 +1229,15 @@ self =>
skipIt = true)(EmptyTree)
// Like Swiss cheese, with holes
def stringCheese: Tree = atPos(in.offset) {
- val start = in.offset
+ val start = in.offset
val interpolator = in.name.encoded // ident() for INTERPOLATIONID
val partsBuf = new ListBuffer[Tree]
- val exprBuf = new ListBuffer[Tree]
+ val exprsBuf = new ListBuffer[Tree]
in.nextToken()
while (in.token == STRINGPART) {
partsBuf += literal()
- exprBuf += (
+ exprsBuf += (
if (inPattern) dropAnyBraces(pattern())
else in.token match {
case IDENTIFIER => atPos(in.offset)(Ident(ident()))
@@ -1260,7 +1256,7 @@ self =>
val t2 = atPos(start) { Apply(t1, partsBuf.toList) }
t2 setPos t2.pos.makeTransparent
val t3 = Select(t2, interpolator) setPos t2.pos
- atPos(start) { Apply(t3, exprBuf.toList) }
+ atPos(start) { Apply(t3, exprsBuf.toList) }
}
if (inPattern) stringCheese
else withPlaceholders(stringCheese, isAny = true) // strinterpolator params are Any* by definition
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 572497ac90..5ae9fd3f56 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -688,9 +688,11 @@ trait Scanners extends ScannersCommon {
setStrVal()
nextChar()
token = STRINGLIT
- } else syntaxError("unclosed string literal")
+ } else unclosedStringLit()
}
+ private def unclosedStringLit(): Unit = syntaxError("unclosed string literal")
+
private def getRawStringLit(): Unit = {
if (ch == '\"') {
nextRawChar()
@@ -764,7 +766,7 @@ trait Scanners extends ScannersCommon {
if (multiLine)
incompleteInputError("unclosed multi-line string literal")
else
- syntaxError("unclosed string literal")
+ unclosedStringLit()
}
else {
putChar(ch)
@@ -1068,21 +1070,19 @@ trait Scanners extends ScannersCommon {
// Errors -----------------------------------------------------------------
- /** generate an error at the given offset
- */
- def syntaxError(off: Offset, msg: String) {
+ /** generate an error at the given offset */
+ def syntaxError(off: Offset, msg: String): Unit = {
error(off, msg)
token = ERROR
}
- /** generate an error at the current token offset
- */
+ /** generate an error at the current token offset */
def syntaxError(msg: String): Unit = syntaxError(offset, msg)
def deprecationWarning(msg: String): Unit = deprecationWarning(offset, msg)
/** signal an error where the input ended in the middle of a token */
- def incompleteInputError(msg: String) {
+ def incompleteInputError(msg: String): Unit = {
incompleteInputError(offset, msg)
token = EOF
}