diff --git a/parsley/shared/src/main/scala/parsley/token/symbol/ConcreteSymbol.scala b/parsley/shared/src/main/scala/parsley/token/symbol/ConcreteSymbol.scala index 2461124e8..94e0dede0 100644 --- a/parsley/shared/src/main/scala/parsley/token/symbol/ConcreteSymbol.scala +++ b/parsley/shared/src/main/scala/parsley/token/symbol/ConcreteSymbol.scala @@ -5,6 +5,8 @@ */ package parsley.token.symbol +import scala.annotation.nowarn + import parsley.Parsley, Parsley.atomic import parsley.character.{char, string} import parsley.token.descriptions.{NameDesc, SymbolDesc} @@ -22,7 +24,7 @@ private [token] class ConcreteSymbol(nameDesc: NameDesc, symbolDesc: SymbolDesc, override def apply(name: String): Parsley[Unit] = { require(name.nonEmpty, "Symbols may not be empty strings") - lazy val compatLabel = err.labelSymbolPunctuation.get(name).map { + lazy val compatLabel = (err.labelSymbolPunctuation: @nowarn).get(name).map { case None => parsley.token.errors.Hidden case Some(l) => parsley.token.errors.Label(l) }.getOrElse(NotConfigured) @@ -36,12 +38,12 @@ private [token] class ConcreteSymbol(nameDesc: NameDesc, symbolDesc: SymbolDesc, override def softKeyword(name: String): Parsley[Unit] = { require(name.nonEmpty, "Keywords may not be empty strings") new Parsley(new token.SoftKeyword(name, nameDesc.identifierLetter, symbolDesc.caseSensitive, - err.labelSymbol.getOrElse(name, err.labelSymbolKeyword(name)), err.labelSymbolEndOfKeyword(name))) + err.labelSymbol.getOrElse(name, err.labelSymbolKeyword(name): @nowarn), err.labelSymbolEndOfKeyword(name))) } override def softOperator(name: String): Parsley[Unit] = { require(name.nonEmpty, "Operators may not be empty strings") new Parsley(new token.SoftOperator(name, nameDesc.operatorLetter, symbolDesc.hardOperatorsTrie, - err.labelSymbol.getOrElse(name, err.labelSymbolOperator(name)), err.labelSymbolEndOfOperator(name))) + err.labelSymbol.getOrElse(name, err.labelSymbolOperator(name): @nowarn), err.labelSymbolEndOfOperator(name))) } } diff --git a/parsley/shared/src/main/scala/parsley/token/symbol/Symbol.scala b/parsley/shared/src/main/scala/parsley/token/symbol/Symbol.scala index 9b01f929c..1f39573a3 100644 --- a/parsley/shared/src/main/scala/parsley/token/symbol/Symbol.scala +++ b/parsley/shared/src/main/scala/parsley/token/symbol/Symbol.scala @@ -5,6 +5,8 @@ */ package parsley.token.symbol +import scala.annotation.nowarn + import parsley.Parsley import parsley.errors.combinator.ErrorMethods import parsley.token.errors.{ErrorConfig, LabelWithExplainConfig} @@ -143,62 +145,62 @@ abstract class Symbol private[symbol] (err: ErrorConfig) { * * @since 4.0.0 */ - final lazy val semi: Parsley[Unit] = apply(';', err.labelSymbolSemi) + final lazy val semi: Parsley[Unit] = apply(';', err.labelSymbolSemi: @nowarn) /** This parser parses a comma `,` as a symbol. * * @since 4.0.0 */ - final lazy val comma: Parsley[Unit] = apply(',', err.labelSymbolComma) + final lazy val comma: Parsley[Unit] = apply(',', err.labelSymbolComma: @nowarn) /** This parser parses a colon `:` as a symbol. * * @since 4.0.0 */ - final lazy val colon: Parsley[Unit] = apply(':', err.labelSymbolColon) + final lazy val colon: Parsley[Unit] = apply(':', err.labelSymbolColon: @nowarn) /** This parser parses a dot `.` as a symbol. * * @since 4.0.0 */ - final lazy val dot: Parsley[Unit] = apply('.', err.labelSymbolDot) + final lazy val dot: Parsley[Unit] = apply('.', err.labelSymbolDot: @nowarn) /** This parser parses an open parenthesis `(` as a symbol. * * @since 4.0.0 */ - final lazy val openParen: Parsley[Unit] = apply('(', err.labelSymbolOpenParen) + final lazy val openParen: Parsley[Unit] = apply('(', err.labelSymbolOpenParen: @nowarn) /** This parser parses an open brace `{` as a symbol. * * @since 4.0.0 */ - final lazy val openBrace: Parsley[Unit] = apply('{', err.labelSymbolOpenBrace) + final lazy val openBrace: Parsley[Unit] = apply('{', err.labelSymbolOpenBrace: @nowarn) /** This parser parses an open square bracket `[` as a symbol. * * @since 4.0.0 */ - final lazy val openSquare: Parsley[Unit] = apply('[', err.labelSymbolOpenSquare) + final lazy val openSquare: Parsley[Unit] = apply('[', err.labelSymbolOpenSquare: @nowarn) /** This parser parses an open angle bracket `<` as a symbol. * * @since 4.0.0 */ - final lazy val openAngle: Parsley[Unit] = apply('<', err.labelSymbolOpenAngle) + final lazy val openAngle: Parsley[Unit] = apply('<', err.labelSymbolOpenAngle: @nowarn) /** This parser parses a closing parenthesis `)` as a symbol. * * @since 4.0.0 */ - final lazy val closingParen: Parsley[Unit] = apply(')', err.labelSymbolClosingParen) + final lazy val closingParen: Parsley[Unit] = apply(')', err.labelSymbolClosingParen: @nowarn) /** This parser parses a closing brace `}` as a symbol. * * @since 4.0.0 */ - final lazy val closingBrace: Parsley[Unit] = apply('}', err.labelSymbolClosingBrace) + final lazy val closingBrace: Parsley[Unit] = apply('}', err.labelSymbolClosingBrace: @nowarn) /** This parser parses a closing square bracket `]` as a symbol. * * @since 4.0.0 */ - final lazy val closingSquare: Parsley[Unit] = apply(']', err.labelSymbolClosingSquare) + final lazy val closingSquare: Parsley[Unit] = apply(']', err.labelSymbolClosingSquare: @nowarn) /** This parser parses a closing square bracket `>` as a symbol. * * @since 4.0.0 */ - final lazy val closingAngle: Parsley[Unit] = apply('>', err.labelSymbolClosingAngle) + final lazy val closingAngle: Parsley[Unit] = apply('>', err.labelSymbolClosingAngle: @nowarn) // $COVERAGE-ON$ } diff --git a/parsley/shared/src/test/scala/parsley/token/symbol/OriginalSymbol.scala b/parsley/shared/src/test/scala/parsley/token/symbol/OriginalSymbol.scala index 5df2d7d44..bd353e873 100644 --- a/parsley/shared/src/test/scala/parsley/token/symbol/OriginalSymbol.scala +++ b/parsley/shared/src/test/scala/parsley/token/symbol/OriginalSymbol.scala @@ -5,6 +5,8 @@ */ package parsley.token.symbol +import scala.annotation.nowarn + import parsley.Parsley, Parsley.{atomic, empty, notFollowedBy, unit} import parsley.character.{char, string, strings} import parsley.unicode @@ -45,7 +47,7 @@ private [token] class OriginalSymbol(nameDesc: NameDesc, symbolDesc: SymbolDesc, override def softKeyword(name: String): Parsley[Unit] = { require(name.nonEmpty, "Keywords may not be empty strings") atomic { - err.labelSymbolKeyword(name)(caseString(name)) *> + err.labelSymbol.getOrElse(name, err.labelSymbolKeyword(name): @nowarn)(caseString(name)) *> notFollowedBy(identLetter).label(err.labelSymbolEndOfKeyword(name)) } } @@ -58,11 +60,11 @@ private [token] class OriginalSymbol(nameDesc: NameDesc, symbolDesc: SymbolDesc, }.toList ends match { case Nil => atomic { - err.labelSymbolOperator(name)(string(name)) *> + err.labelSymbol.getOrElse(name, err.labelSymbolOperator(name): @nowarn)(string(name)) *> notFollowedBy(opLetter).label(err.labelSymbolEndOfOperator(name)) } case end::ends => atomic { - err.labelSymbolOperator(name)(string(name)) *> + err.labelSymbol.getOrElse(name, err.labelSymbolOperator(name): @nowarn)(string(name)) *> notFollowedBy(opLetter <|> strings(end, ends: _*)).label(err.labelSymbolEndOfOperator(name)) } }