mirror of
https://github.com/nlohmann/json.git
synced 2026-10-23 14:28:54 +00:00
2.3.6: table of control-character messages in the lexer (#5891)
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 file changed
+36
-156
@@ -656,194 +656,74 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
|
||||
// invalid control characters
|
||||
case 0x00:
|
||||
{
|
||||
error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x01:
|
||||
{
|
||||
error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x02:
|
||||
{
|
||||
error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x03:
|
||||
{
|
||||
error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x04:
|
||||
{
|
||||
error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x05:
|
||||
{
|
||||
error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x06:
|
||||
{
|
||||
error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x07:
|
||||
{
|
||||
error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x08:
|
||||
{
|
||||
error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x09:
|
||||
{
|
||||
error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x0A:
|
||||
{
|
||||
error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x0B:
|
||||
{
|
||||
error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x0C:
|
||||
{
|
||||
error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x0D:
|
||||
{
|
||||
error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x0E:
|
||||
{
|
||||
error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x0F:
|
||||
{
|
||||
error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x10:
|
||||
{
|
||||
error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x11:
|
||||
{
|
||||
error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x12:
|
||||
{
|
||||
error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x13:
|
||||
{
|
||||
error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x14:
|
||||
{
|
||||
error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x15:
|
||||
{
|
||||
error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x16:
|
||||
{
|
||||
error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x17:
|
||||
{
|
||||
error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x18:
|
||||
{
|
||||
error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x19:
|
||||
{
|
||||
error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x1A:
|
||||
{
|
||||
error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x1B:
|
||||
{
|
||||
error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x1C:
|
||||
{
|
||||
error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x1D:
|
||||
{
|
||||
error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x1E:
|
||||
{
|
||||
error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
case 0x1F:
|
||||
{
|
||||
error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F";
|
||||
static const char* const control_character_messages[32] =
|
||||
{
|
||||
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000",
|
||||
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001",
|
||||
"invalid string: control character U+0002 (STX) must be escaped to \\u0002",
|
||||
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003",
|
||||
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004",
|
||||
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005",
|
||||
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006",
|
||||
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007",
|
||||
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b",
|
||||
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t",
|
||||
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n",
|
||||
"invalid string: control character U+000B (VT) must be escaped to \\u000B",
|
||||
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f",
|
||||
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r",
|
||||
"invalid string: control character U+000E (SO) must be escaped to \\u000E",
|
||||
"invalid string: control character U+000F (SI) must be escaped to \\u000F",
|
||||
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010",
|
||||
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011",
|
||||
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012",
|
||||
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013",
|
||||
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014",
|
||||
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015",
|
||||
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016",
|
||||
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017",
|
||||
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018",
|
||||
"invalid string: control character U+0019 (EM) must be escaped to \\u0019",
|
||||
"invalid string: control character U+001A (SUB) must be escaped to \\u001A",
|
||||
"invalid string: control character U+001B (ESC) must be escaped to \\u001B",
|
||||
"invalid string: control character U+001C (FS) must be escaped to \\u001C",
|
||||
"invalid string: control character U+001D (GS) must be escaped to \\u001D",
|
||||
"invalid string: control character U+001E (RS) must be escaped to \\u001E",
|
||||
"invalid string: control character U+001F (US) must be escaped to \\u001F"
|
||||
};
|
||||
error_message = control_character_messages[static_cast<std::size_t>(current)];
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user