fix: escape characters within assembly

This commit is contained in:
2025-02-25 17:07:21 +00:00
parent 8558733719
commit 5f8b87221c
2 changed files with 22 additions and 10 deletions

View File

@@ -39,6 +39,17 @@ val errConfig = new ErrorConfig {
)
}
object lexer {
val escapedChars: Map[String, Int] = Map(
"0" -> '\u0000',
"b" -> '\b',
"t" -> '\t',
"n" -> '\n',
"f" -> '\f',
"r" -> '\r',
"\\" -> '\\',
"'" -> '\'',
"\"" -> '\"'
)
/** Language description for the WACC lexer
*/
@@ -63,15 +74,9 @@ object lexer {
textDesc = TextDesc.plain.copy(
graphicCharacter = Basic(c => c >= ' ' && c != '\\' && c != '\'' && c != '"'),
escapeSequences = EscapeDesc.plain.copy(
literals = Set('\\', '"', '\''),
mapping = Map(
"0" -> '\u0000',
"b" -> '\b',
"t" -> '\t',
"n" -> '\n',
"f" -> '\f',
"r" -> '\r'
)
literals =
escapedChars.filter { (s, chr) => chr.toChar.toString == s }.map(_._2.toChar).toSet,
mapping = escapedChars.filter { (s, chr) => chr.toChar.toString != s }
)
),
numericDesc = NumericDesc.plain.copy(