Re-assign JSON quirk numbers

This commit is contained in:
Nigel Tao committed 2020-04-07 17:17:54 +10:00
1 parent b5d6f8d038
commit 2db72dabe5
4 files changed
+70 -69

No files matched your search

+13 -12
View File
@@ -68,10 +68,11 @@ pri const decoder_number_length_max_incl base.u64 = 99
// validity depends on the relevant quirk. The element's value is an enum:
// - 1: "\a", U+0007, quirk_allow_backslash_a.
// - 2: "\e", U+001B, quirk_allow_backslash_e.
// - 3: "\?", U+003F, quirk_allow_backslash_question_mark.
// - 4: "\'", U+0027, quirk_allow_backslash_single_quote.
// - 5: "\v", U+000B, quirk_allow_backslash_v.
// - 6: "\0", U+0000, quirk_allow_backslash_zero.
// - 3: "backslash new_line(not_n)", U+000A, quirk_allow_backslash_new_line.
// - 4: "\?", U+003F, quirk_allow_backslash_question_mark.
// - 5: "\'", U+0027, quirk_allow_backslash_single_quote.
// - 6: "\v", U+000B, quirk_allow_backslash_v.
// - 7: "\0", U+0000, quirk_allow_backslash_zero.
// The U+1234 values are held in lut_quirky_backslashes, below.
//
// If the element is zero then "\i" is invalid, or it is a special case, the
@@ -80,13 +81,13 @@ pri const lut_backslashes array[256] base.u8 = [
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F. '\n'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.
0x00, 0x00, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x04, // 0x20 ..= 0x27. '"', '\''.
0x00, 0x00, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x05, // 0x20 ..= 0x27. '"', '\''.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, // 0x28 ..= 0x2F. '/'.
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x30 ..= 0x37. '0'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // 0x38 ..= 0x3F. '?'
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x30 ..= 0x37. '0'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, // 0x38 ..= 0x3F. '?'
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.
@@ -94,7 +95,7 @@ pri const lut_backslashes array[256] base.u8 = [
0x00, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F. '\\'.
0x00, 0x01, 0x88, 0x00, 0x00, 0x02, 0x8C, 0x00, // 0x60 ..= 0x67. 'a', 'b', 'e', 'f'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x00, // 0x68 ..= 0x6F. 'n'.
0x00, 0x00, 0x8D, 0x00, 0x89, 0x00, 0x05, 0x00, // 0x70 ..= 0x77. 'r', 't', 'v'.
0x00, 0x00, 0x8D, 0x00, 0x89, 0x00, 0x06, 0x00, // 0x70 ..= 0x77. 'r', 't', 'v'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87.
@@ -119,10 +120,10 @@ pri const lut_backslashes array[256] base.u8 = [
]
// lut_quirky_backslashes is discussed in the lut_backslashes comment. The
// first and last elements (indexes 0 and 7) are not used, but 8 is a round
// power of 2, so enforcing index-in-bounds is a simple "&7" operation.
// first element (index 0) is not used, but 8 is a round power of 2, so
// enforcing index-in-bounds is a simple "&7" operation.
pri const lut_quirky_backslashes array[8] base.u8 = [
0x00, 0x07, 0x1B, 0x3F, 0x27, 0x0B, 0x00, 0x00,
0x00, 0x07, 0x1B, 0x0A, 0x3F, 0x27, 0x0B, 0x00,
]
// lut_chars helps decode bytes within a string: