Skip to content

Commit

Permalink
removed redundant escape char check for characters
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 committed Jan 16, 2024
1 parent 83d13a7 commit 9063571
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,6 @@ private [text] object CharacterParsers {
case NotRequired => NotRequired
}

def letter(terminalLead: Char, escapeLead: Char, allowsAllSpace: Boolean, isGraphic: CharPredicate): CharPredicate = {
letter(terminalLead, allowsAllSpace, isGraphic) match {
case Unicode(g) => Unicode(c => c != escapeLead.toInt && g(c))
case Basic(g) => Basic(c => c != escapeLead && g(c))
case NotRequired => NotRequired
}
}

@inline def isBmpCodePoint(codepoint: Int): Boolean = java.lang.Character.isBmpCodePoint(codepoint)
@inline def isValidCodePoint(codepoint: Int): Boolean = java.lang.Character.isValidCodePoint(codepoint)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import parsley.token.errors.{ErrorConfig, FilterConfig, LabelConfig, LabelWithEx

private [token] final class ConcreteCharacter(desc: TextDesc, escapes: Escape, err: ErrorConfig) extends CharacterParsers {
private val quote = char(desc.characterLiteralEnd)
private lazy val graphic = CharacterParsers.letter(desc.characterLiteralEnd, desc.escapeSequences.escBegin, allowsAllSpace = false, desc.graphicCharacter)
private lazy val graphic = CharacterParsers.letter(desc.characterLiteralEnd, allowsAllSpace = false, desc.graphicCharacter)

private def charLetter(graphicLetter: Parsley[Int]) = {
// escapeChar is not atomic, so we don't need to rule out escape begin in graphic
escapes.escapeChar <|> err.labelGraphicCharacter(graphicLetter) <|> err.verifiedCharBadCharsUsedInLiteral.checkBadChar
}
private def charLiteral[A](letter: Parsley[A], end: LabelConfig) = quote *> letter <* end(quote)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ private [token] class Escape(desc: EscapeDesc, err: ErrorConfig, generic: numeri
private val numericEscape = decimalEscape <|> hexadecimalEscape <|> octalEscape <|> binaryEscape
val escapeCode = err.labelEscapeEnd(escMapped <|> numericEscape)
val escapeBegin = err.labelEscapeSequence(char(desc.escBegin)).void
// do not make atomic
val escapeChar = escapeBegin *> escapeCode
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private [token] class OriginalEscape(desc: EscapeDesc, err: ErrorConfig, generic
private val numericEscape = decimalEscape <|> hexadecimalEscape <|> octalEscape <|> binaryEscape
val escapeCode = err.labelEscapeEnd(escMapped <|> numericEscape)
val escapeBegin = err.labelEscapeSequence(char(desc.escBegin)).void
// do not make atomic
val escapeChar = escapeBegin *> escapeCode
}
// $COVERAGE-ON$

0 comments on commit 9063571

Please sign in to comment.