Skip to content

Commit

Permalink
suppressed deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 committed Jan 29, 2024
1 parent 40ed20d commit 45096a9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
Expand All @@ -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)))
}
}
26 changes: 14 additions & 12 deletions parsley/shared/src/main/scala/parsley/token/symbol/Symbol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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$
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
}
Expand All @@ -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))
}
}
Expand Down

0 comments on commit 45096a9

Please sign in to comment.