aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnno Runne <enno.runne@baymarkets.com>2017-02-16 21:11:16 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-02-20 16:50:09 +0100
commit4352a4a97817edfbd4e936258050c17bfff187c3 (patch)
tree3f86b6109f6db6ccf718758bc040527f76afb556
parente668fd7eaf93a81d0409728664a0f2bda4a63761 (diff)
downloaddotty-4352a4a97817edfbd4e936258050c17bfff187c3.tar.gz
dotty-4352a4a97817edfbd4e936258050c17bfff187c3.tar.bz2
dotty-4352a4a97817edfbd4e936258050c17bfff187c3.zip
Incorporated comments from @felixmulder
-rw-r--r--compiler/src/dotty/tools/dotc/parsing/Parsers.scala8
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala15
2 files changed, 12 insertions, 11 deletions
diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
index 8f146e920..b46bc401d 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -404,13 +404,13 @@ object Parsers {
var opStack: List[OpInfo] = Nil
- def checkAssoc(offset: Int, op: Name, leftAssoc: Boolean, op2: Name) =
- if (isLeftAssoc(op) != leftAssoc)
- syntaxError(MixedLeftAndRightAssociativeOps(op, op2, leftAssoc), offset)
+ def checkAssoc(offset: Token, op1: Name, op2: Name, op2LeftAssoc: Boolean): Unit =
+ if (isLeftAssoc(op1) != op2LeftAssoc)
+ syntaxError(MixedLeftAndRightAssociativeOps(op1, op2, op2LeftAssoc), offset)
def reduceStack(base: List[OpInfo], top: Tree, prec: Int, leftAssoc: Boolean, op2: Name): Tree = {
if (opStack != base && precedence(opStack.head.operator.name) == prec)
- checkAssoc(opStack.head.offset, opStack.head.operator.name, leftAssoc, op2)
+ checkAssoc(opStack.head.offset, opStack.head.operator.name, op2, leftAssoc)
def recur(top: Tree): Tree = {
if (opStack == base) top
else {
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index f8222ce92..ed1c5642f 100644
--- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -1098,20 +1098,21 @@ object messages {
val kind = "Syntax"
val op1Asso = if (op2LeftAssoc) "which is right-associative" else "which is left-associative"
val op2Asso = if (op2LeftAssoc) "which is left-associative" else "which is right-associative"
- val msg = s"${hl"`${op1}`"} (${op1Asso}) and ${hl"`${op2}`"} ($op2Asso) have same precedence and may not be mixed"
+ val msg = s"`${op1}` (${op1Asso}) and `${op2}` ($op2Asso) have same precedence and may not be mixed"
val explanation =
- s"""|The operators ${hl"${op1}"} and ${hl"${op2}"} are used as infix operators in the same expression,
+ s"""|The operators ${op1} and ${op2} are used as infix operators in the same expression,
|but they bind to different sides:
- |${hl"${op1}"} is applied to the operand to its ${if (op2LeftAssoc) "right" else "left"}
- |${hl"${op2}"} is applied to the operand to its ${if (op2LeftAssoc) "left" else "right"}
+ |${op1} is applied to the operand to its ${if (op2LeftAssoc) "right" else "left"}
+ |${op2} is applied to the operand to its ${if (op2LeftAssoc) "left" else "right"}
|As both have the same precedence the compiler can't decide which to apply first.
|
|You may use parenthesis to make the application order explicit,
- |or use method application syntax ${hl"`operand1.${op1}(operand2)`"}.
+ |or use method application syntax `operand1.${op1}(operand2)`.
|
|Operators ending in a colon `:` are right-associative. All other operators are left-associative.
|
- |Infix operator precedence is determined by the operator's first character:
+ |Infix operator precedence is determined by the operator's first character. Characters are listed
+ |below in increasing order of precedence, with characters on the same line having the same precedence.
| (all letters)
| |
| ^
@@ -1122,7 +1123,7 @@ object messages {
| + -
| * / %
| (all other special characters)
- |Operators starting with a letter have lowest precedence, followed by operators starting with `|', etc.
+ |Operators starting with a letter have lowest precedence, followed by operators starting with `|`, etc.
|""".stripMargin
}