Skip to content

Commit

Permalink
removed validation, the problematic interactions are gone now
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 committed Jan 5, 2023
1 parent 42da6a4 commit 92483e4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 36 deletions.
2 changes: 0 additions & 2 deletions parsley/shared/src/main/scala/parsley/token/Lexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ class Lexer(desc: descriptions.LexicalDesc, errConfig: errors.ErrorConfig) {
*/
def this(desc: descriptions.LexicalDesc) = this(desc, errors.ErrorConfig.default)

if (!errConfig.pleaseDontValidateConfig) errConfig.validateConfig()

private val generic = new numeric.Generic(errConfig)

/** This object is concerned with ''lexemes'': these are tokens that are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,6 @@ import parsley.position
*/
// TODO: We could make these groupings into merged ADTs? Must be careful with binary-lock-in though...
class ErrorConfig {
// Right, I give up. Some of the interactions between these configurations are absurd, so I need
// to guard against stuff that's just plain odd:
def pleaseDontValidateConfig = false
private [token] final def validateConfig(): Unit = {
val bits = List(8, 16, 32, 64)
def badEnd(ty: String) = s"cannot specify the end of a $ty integer literal without specifying the start or unsigned and signed $ty literals"
require(labelIntegerBinaryEnd.isEmpty ||
(labelIntegerSignedBinary ::
labelIntegerUnsignedBinary ::
bits.map(labelIntegerSignedBinary) :::
bits.map(labelIntegerUnsignedBinary)).forall(_.nonEmpty), badEnd("binary"))
require(labelIntegerDecimalEnd.isEmpty ||
(labelIntegerSignedDecimal ::
labelIntegerUnsignedDecimal ::
bits.map(labelIntegerSignedDecimal) :::
bits.map(labelIntegerUnsignedDecimal)).forall(_.nonEmpty), badEnd("decimal"))
require(labelIntegerHexadecimalEnd.isEmpty ||
(labelIntegerSignedHexadecimal ::
labelIntegerUnsignedHexadecimal ::
bits.map(labelIntegerSignedHexadecimal) :::
bits.map(labelIntegerUnsignedHexadecimal)).forall(_.nonEmpty), badEnd("hexadecimal"))
require(labelIntegerOctalEnd.isEmpty ||
(labelIntegerSignedOctal ::
labelIntegerUnsignedOctal ::
bits.map(labelIntegerSignedOctal) :::
bits.map(labelIntegerUnsignedOctal)).forall(_.nonEmpty), badEnd("octal"))
require(labelIntegerNumberEnd.isEmpty ||
(labelIntegerSignedNumber ::
labelIntegerUnsignedNumber ::
bits.map(labelIntegerSignedNumber) :::
bits.map(labelIntegerUnsignedNumber)).forall(_.nonEmpty), badEnd("number"))
}

// numeric
def labelNumericBreakChar: Option[String] = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ private [token] final class UnsignedReal(desc: NumericDesc, natural: UnsignedInt
val (requiredExponent, exponent, base) = expDesc match {
case ExponentDesc.Supported(compulsory, exp, base, sign) =>
val expErr = new ErrorConfig {
override def pleaseDontValidateConfig: Boolean = true
override def labelIntegerSignedDecimal(bits: Int): Option[String] = err.labelRealExponentEnd.orElse(endLabel)
override def labelIntegerDecimalEnd: Option[String] = err.labelRealExponentEnd.orElse(endLabel)
}
Expand Down

0 comments on commit 92483e4

Please sign in to comment.