From 4352a4a97817edfbd4e936258050c17bfff187c3 Mon Sep 17 00:00:00 2001 From: Enno Runne Date: Thu, 16 Feb 2017 21:11:16 +0100 Subject: Incorporated comments from @felixmulder --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 8 ++++---- .../dotty/tools/dotc/reporting/diagnostic/messages.scala | 15 ++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'compiler/src/dotty/tools/dotc') 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 } -- cgit v1.2.3