Redo Wuffs structs' quirk bool fields

This commit is contained in:
Nigel Tao committed 2020-04-14 23:03:18 +10:00
1 parent 532e18c4a5
commit e39f3cbf42
7 files changed
+162 -290

No files matched your search

+26 -11
View File
@@ -66,14 +66,15 @@ pri const DECODER_NUMBER_LENGTH_MAX_INCL : base.u64 = 99
//
// If the element is non-zero (but the 0x80 bit is not set) then "\i"'s
// 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: "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.
// - 1: "\a", U+0007, QUIRK_ALLOW_BACKSLASH_A.
// - 2: "\e", U+001B, QUIRK_ALLOW_BACKSLASH_E.
// - 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 quirk and U+1234 values are held in LUT_QUIRKY_BACKSLASHES_QUIRKS and
// LUT_QUIRKY_BACKSLASHES_CHARS, below.
//
// If the element is zero then "\i" is invalid, or it is a special case, the
// start of "\x12", "\u1234" or "\U12345678".
@@ -119,10 +120,24 @@ pri const LUT_BACKSLASHES : array[256] base.u8 = [
// 8 9 A B C D E F
]
// LUT_QUIRKY_BACKSLASHES is discussed in the LUT_BACKSLASHES comment. The
// first element (index 0) is not used, but 8 is a round power of 2, so
// LUT_QUIRKY_BACKSLASHES_QUIRKS is discussed in the LUT_BACKSLASHES comment.
// The 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 = [
pri const LUT_QUIRKY_BACKSLASHES_QUIRKS : array[8] base.u8[..= 0x09] = [
0,
0x01, // (QUIRK_ALLOW_BACKSLASH_A - QUIRKS_BASE) as base.u8,
0x03, // (QUIRK_ALLOW_BACKSLASH_E - QUIRKS_BASE) as base.u8,
0x04, // (QUIRK_ALLOW_BACKSLASH_NEW_LINE - QUIRKS_BASE) as base.u8,
0x05, // (QUIRK_ALLOW_BACKSLASH_QUESTION_MARK - QUIRKS_BASE) as base.u8,
0x06, // (QUIRK_ALLOW_BACKSLASH_SINGLE_QUOTE - QUIRKS_BASE) as base.u8,
0x07, // (QUIRK_ALLOW_BACKSLASH_V - QUIRKS_BASE) as base.u8,
0x09, // (QUIRK_ALLOW_BACKSLASH_ZERO - QUIRKS_BASE) as base.u8,
]
// LUT_QUIRKY_BACKSLASHES_CHARS is discussed in the LUT_BACKSLASHES comment.
// The 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_CHARS : array[8] base.u8 = [
0x00, 0x07, 0x1B, 0x0A, 0x3F, 0x27, 0x0B, 0x00,
]