| // Copyright 2020 The Wuffs Authors. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // https://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| pub status "#bad C0 control code" |
| pub status "#bad UTF-8" |
| pub status "#bad backslash-escape" |
| pub status "#bad input" |
| pub status "#bad new-line in a string" |
| pub status "#bad quirk combination" |
| pub status "#unsupported number length" |
| pub status "#unsupported recursion depth" |
| |
| pri status "#internal error: inconsistent I/O" |
| |
| // -------- |
| |
| // DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE is the largest workbuf length that a |
| // decoder will request. |
| pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0 |
| |
| // DECODER_DEPTH_MAX_INCL is the maximum supported recursion depth: how deeply |
| // nested [] arrays and {} objects can be. |
| // |
| // The JSON spec itself does not define a limit, but allows implementations to |
| // set their own limits. |
| pub const DECODER_DEPTH_MAX_INCL : base.u64 = 1024 |
| |
| // DECODER_DST_TOKEN_BUFFER_LENGTH_MIN_INCL is the minimum length of the dst |
| // wuffs_base__token_buffer passed to the decoder. |
| pub const DECODER_DST_TOKEN_BUFFER_LENGTH_MIN_INCL : base.u64 = 1 |
| |
| // DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL is the minimum length of the src |
| // wuffs_base__io_buffer passed to the decoder. |
| // |
| // This constrains the src.data.len field and it is the io_buffer capacity (the |
| // maximum possible src.meta.ri and src.meta.wi values). It is a property of |
| // the backing array's length, not the length of the JSON-formatted input per |
| // se. It is perfectly valid to decode "[1,2]" (of length 5) as JSON, as long |
| // as that content is placed in an io_buffer whose data.len is at least 100. |
| pub const DECODER_SRC_IO_BUFFER_LENGTH_MIN_INCL : base.u64 = 100 |
| |
| // DECODER_NUMBER_LENGTH_MAX_INCL is the longest supported byte length for a |
| // JSON number. Unlike JSON strings, this package's tokenizer never splits a |
| // single JSON number into multiple tokens, as this simplifies the callers. |
| // They can then call e.g. wuffs_base__parse_number_i64 without having to |
| // reconstitute a contiguous string representation. |
| // |
| // The JSON spec itself does not define a limit, but allows implementations to |
| // set their own limits. |
| pri const DECODER_NUMBER_LENGTH_MAX_INCL : base.u64 = 99 |
| |
| // -------- |
| |
| // Look-Up Tables (LUTs). |
| |
| // LUT_BACKSLASHES[i] helps decode "\i", for various 'i's. |
| // |
| // If the element's 0x80 bit is set then "\i" is unconditionally a valid |
| // single-output-byte backslash-escape. The low 7 bits are the unescaped value. |
| // For example, LUT_BACKSLASHES['n'] is (0x80 | 0x0A), because "\n" is U+000A. |
| // |
| // 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 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". |
| 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, 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, 0x05, // 0x20 ..= 0x27. '"', '\''. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, // 0x28 ..= 0x2F. '/'. |
| 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. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57. |
| 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, 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. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB8 ..= 0xBF. |
| |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF. |
| // 0 1 2 3 4 5 6 7 |
| // 8 9 A B C D E F |
| ] |
| |
| // 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_QUIRKS : array[8] base.u8[..= 0x0A] = [ |
| 0, |
| // Uncommenting the following lines requires being able to define consts in |
| // terms of other consts, which could be non-trivial to specify and |
| // implement (to avoid infinite loops). |
| 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, |
| 0x0A, // (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, |
| ] |
| |
| // LUT_CHARS helps decode bytes within a string: |
| // - 0x00 is 1-byte UTF-8 (ASCII) but not '"', '\\' or a C0 control code. |
| // - 0x01 is '"'. |
| // - 0x02 is '\\'. |
| // - 0x03 is the start of 2-byte UTF-8. |
| // - 0x04 is the start of 3-byte UTF-8. |
| // - 0x05 is the start of 4-byte UTF-8. |
| // - 0x10 is a UTF-8 tail byte. |
| // - 0x20 is invalid UTF-8. |
| // - 0x80 and above is invalid JSON (C0 control codes). |
| // |
| // RFC 3629 (UTF-8) gives this grammar for valid UTF-8: |
| // UTF8-1 = %x00-7F |
| // UTF8-2 = %xC2-DF UTF8-tail |
| // UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) / |
| // %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail ) |
| // UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) / |
| // %xF4 %x80-8F 2( UTF8-tail ) |
| // UTF8-tail = %x80-BF |
| pri const LUT_CHARS : array[256] base.u8 = [ |
| // 0 1 2 3 4 5 6 7 |
| // 8 9 A B C D E F |
| 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x00 ..= 0x07. C0 control codes. |
| 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, // 0x08 ..= 0x0F. C0 control codes. |
| 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, // 0x10 ..= 0x17. C0 control codes. |
| 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, // 0x18 ..= 0x1F. C0 control codes. |
| 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27. UTF-8-1; '"'. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F. UTF-8-1. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x30 ..= 0x37. UTF-8-1. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. UTF-8-1. |
| |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47. UTF-8-1. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F. UTF-8-1. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57. UTF-8-1. |
| 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F. UTF-8-1; '\\'. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60 ..= 0x67. UTF-8-1. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F. UTF-8-1. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77. UTF-8-1. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F. UTF-8-1. |
| |
| 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0x80 ..= 0x87. UTF-8 tail. |
| 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0x88 ..= 0x8F. UTF-8 tail. |
| 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0x90 ..= 0x97. UTF-8 tail. |
| 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0x98 ..= 0x9F. UTF-8 tail. |
| 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0xA0 ..= 0xA7. UTF-8 tail. |
| 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0xA8 ..= 0xAF. UTF-8 tail. |
| 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0xB0 ..= 0xB7. UTF-8 tail. |
| 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0xB8 ..= 0xBF. UTF-8 tail. |
| |
| 0x20, 0x20, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // 0xC0 ..= 0xC7. Invalid UTF-8; UTF-8-2. |
| 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // 0xC8 ..= 0xCF. UTF-8-2. |
| 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // 0xD0 ..= 0xD7. UTF-8-2. |
| 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // 0xD8 ..= 0xDF. UTF-8-2. |
| 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, // 0xE0 ..= 0xE7. UTF-8-3. |
| 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, // 0xE8 ..= 0xEF. UTF-8-3. |
| 0x05, 0x05, 0x05, 0x05, 0x05, 0x20, 0x20, 0x20, // 0xF0 ..= 0xF7. UTF-8-4; Invalid UTF-8. |
| 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // 0xF8 ..= 0xFF. Invalid UTF-8. |
| // 0 1 2 3 4 5 6 7 |
| // 8 9 A B C D E F |
| ] |
| |
| pri const CLASS_WHITESPACE : base.u8 = 0x00 |
| pri const CLASS_STRING : base.u8 = 0x01 |
| pri const CLASS_COMMA : base.u8 = 0x02 |
| pri const CLASS_COLON : base.u8 = 0x03 |
| pri const CLASS_NUMBER : base.u8 = 0x04 |
| pri const CLASS_OPEN_CURLY_BRACE : base.u8 = 0x05 |
| pri const CLASS_CLOSE_CURLY_BRACE : base.u8 = 0x06 |
| pri const CLASS_OPEN_SQUARE_BRACKET : base.u8 = 0x07 |
| pri const CLASS_CLOSE_SQUARE_BRACKET : base.u8 = 0x08 |
| pri const CLASS_FALSE : base.u8 = 0x09 |
| pri const CLASS_TRUE : base.u8 = 0x0A |
| pri const CLASS_NULL_NAN_INF : base.u8 = 0x0B |
| pri const CLASS_COMMENT : base.u8 = 0x0C |
| |
| // EXPECT_ETC are unions of LUT_CLASSES bitmasks. See LUT_CLASSES below. |
| // |
| // Bitwise or'ing these together gives 0x1FFE. Whitespace is never expected, as |
| // it is handled separately. |
| // |
| // EXPECT_VALUE is also defined to be 0x1EB2, equivalent to (EXPECT_STRING | |
| // EXPECT_NON_STRING_VALUE). |
| // |
| // "Non-string value" includes literals (false, true, null), numbers, arrays |
| // and objects. |
| // |
| // "String value" includes "this" and "th\u0061t". |
| // |
| // Comments are always expected. Whether the relevant quirks are enabled are |
| // checked elsewhere. |
| pri const EXPECT_VALUE : base.u32 = 0x1EB2 |
| pri const EXPECT_NON_STRING_VALUE : base.u32 = 0x1EB0 |
| pri const EXPECT_STRING : base.u32 = 0x1002 |
| pri const EXPECT_COMMA : base.u32 = 0x1004 |
| pri const EXPECT_COLON : base.u32 = 0x1008 |
| pri const EXPECT_NUMBER : base.u32 = 0x1010 |
| pri const EXPECT_CLOSE_CURLY_BRACE : base.u32 = 0x1040 |
| pri const EXPECT_CLOSE_SQUARE_BRACKET : base.u32 = 0x1100 |
| |
| // LUT_CLASSES is: |
| // - 0x00 (bitmask 0x0001) is CLASS_WHITESPACE. |
| // - 0x01 (bitmask 0x0002) is CLASS_STRING. |
| // - 0x02 (bitmask 0x0004) is CLASS_COMMA. |
| // - 0x03 (bitmask 0x0008) is CLASS_COLON. |
| // - 0x04 (bitmask 0x0010) is CLASS_NUMBER. |
| // - 0x05 (bitmask 0x0020) is CLASS_OPEN_CURLY_BRACE. |
| // - 0x06 (bitmask 0x0040) is CLASS_CLOSE_CURLY_BRACE. |
| // - 0x07 (bitmask 0x0080) is CLASS_OPEN_SQUARE_BRACKET. |
| // - 0x08 (bitmask 0x0100) is CLASS_CLOSE_SQUARE_BRACKET. |
| // - 0x09 (bitmask 0x0200) is CLASS_FALSE. |
| // - 0x0A (bitmask 0x0400) is CLASS_TRUE. |
| // - 0x0B (bitmask 0x0800) is CLASS_NULL_NAN_INF. |
| // - 0x0C (bitmask 0x1000) is CLASS_COMMENT. |
| // - 0x0D (bitmask 0x2000) is reserved. |
| // - 0x0E (bitmask 0x4000) is reserved. |
| // - 0x0F (bitmask 0x8000) is CLASS_BAD_INPUT. |
| // |
| // The bitmasks are used by the "expect" variable: what the next character |
| // class can be. See EXPECT_ETC above. |
| pri const LUT_CLASSES : array[256] base.u8[..= 0x0F] = [ |
| // 0 1 2 3 4 5 6 7 |
| // 8 9 A B C D E F |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x00 ..= 0x07. |
| 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x0F, 0x0F, // 0x08 ..= 0x0F. '\t', '\n', '\r'. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x10 ..= 0x17. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x18 ..= 0x1F. |
| 0x00, 0x0F, 0x01, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x20 ..= 0x27. ' ', '"'. |
| 0x0F, 0x0F, 0x0F, 0x0B, 0x02, 0x04, 0x0F, 0x0C, // 0x28 ..= 0x2F. '+', ',', '-', '/'. |
| 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, // 0x30 ..= 0x37. '0'-'7'. |
| 0x04, 0x04, 0x03, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x38 ..= 0x3F. '8'-'9', ':'. |
| |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x40 ..= 0x47. |
| 0x0F, 0x0B, 0x0F, 0x0F, 0x0F, 0x0F, 0x0B, 0x0F, // 0x48 ..= 0x4F. 'I', 'N'. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x50 ..= 0x57. |
| 0x0F, 0x0F, 0x0F, 0x07, 0x0F, 0x08, 0x0F, 0x0F, // 0x58 ..= 0x5F. '[', ']'. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x09, 0x0F, // 0x60 ..= 0x67. 'f'. |
| 0x0F, 0x0B, 0x0F, 0x0F, 0x0F, 0x0F, 0x0B, 0x0F, // 0x68 ..= 0x6F. 'i', 'n'. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0A, 0x0F, 0x0F, 0x0F, // 0x70 ..= 0x77. 't'. |
| 0x0F, 0x0F, 0x0F, 0x05, 0x0F, 0x06, 0x0F, 0x0F, // 0x78 ..= 0x7F. '{', '}'. |
| |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x80 ..= 0x87. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x88 ..= 0x8F. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x90 ..= 0x97. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x98 ..= 0x9F. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xA0 ..= 0xA7. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xA8 ..= 0xAF. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xB0 ..= 0xB7. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xB8 ..= 0xBF. |
| |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xC0 ..= 0xC7. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xC8 ..= 0xCF. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xD0 ..= 0xD7. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xD8 ..= 0xDF. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xE0 ..= 0xE7. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xE8 ..= 0xEF. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xF0 ..= 0xF7. |
| 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0xF8 ..= 0xFF. |
| // 0 1 2 3 4 5 6 7 |
| // 8 9 A B C D E F |
| ] |
| |
| pri const LUT_DECIMAL_DIGITS : 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F. |
| 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x30 ..= 0x37. '0'-'7'. |
| 0x88, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. '8'-'9'. |
| |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60 ..= 0x67. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F. |
| |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB8 ..= 0xBF. |
| |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF. |
| // 0 1 2 3 4 5 6 7 |
| // 8 9 A B C D E F |
| ] |
| |
| pri const LUT_HEXADECIMAL_DIGITS : 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F. |
| 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x30 ..= 0x37. '0'-'7'. |
| 0x88, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. '8'-'9'. |
| |
| 0x00, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x00, // 0x40 ..= 0x47. 'A'-'F'. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F. |
| 0x00, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x00, // 0x60 ..= 0x67. 'a'-'f'. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F. |
| |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB8 ..= 0xBF. |
| |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7. |
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF. |
| // 0 1 2 3 4 5 6 7 |
| // 8 9 A B C D E F |
| ] |