Add std/json CLASS_COMMENT

This commit is contained in:
Nigel Tao committed 2020-03-21 22:33:39 +11:00
1 parent 502c8eff56
commit 21f6a5df4a
3 files changed
+56 -53

No files matched your search

+18 -18
View File
@@ -20291,7 +20291,7 @@ static const uint8_t //
WUFFS_BASE__POTENTIALLY_UNUSED = { WUFFS_BASE__POTENTIALLY_UNUSED = {
15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 15, 15, 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 15, 15, 0, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 15, 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 15, 1, 15,
15, 15, 15, 15, 15, 15, 15, 15, 2, 4, 15, 15, 4, 4, 4, 4, 4, 4, 15, 15, 15, 15, 15, 15, 15, 15, 2, 4, 15, 12, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 3, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 4, 4, 4, 4, 3, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 7, 15, 8, 15, 15, 15, 15, 15, 15, 15, 15, 9, 15, 15, 15, 15, 15, 15, 7, 15, 8, 15, 15, 15, 15, 15, 15, 15, 15, 9, 15, 15, 15, 15, 15,
@@ -20605,7 +20605,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
goto suspend; goto suspend;
} }
} }
v_expect = 3762; v_expect = 7858;
label__outer__continue:; label__outer__continue:;
while (true) { while (true) {
while (true) { while (true) {
@@ -21301,7 +21301,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
} }
label__2__break:; label__2__break:;
if (0 == (v_expect & 16)) { if (0 == (v_expect & 16)) {
v_expect = 8; v_expect = 4104;
goto label__outer__continue; goto label__outer__continue;
} }
goto label__goto_parsed_a_leaf_value__break; goto label__goto_parsed_a_leaf_value__break;
@@ -21311,9 +21311,9 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | (((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT)); (((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
if (0 == (v_expect & 256)) { if (0 == (v_expect & 256)) {
v_expect = 2; v_expect = 4098;
} else { } else {
v_expect = 3762; v_expect = 7858;
} }
goto label__outer__continue; goto label__outer__continue;
} else if (v_class == 3) { } else if (v_class == 3) {
@@ -21321,7 +21321,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
*iop_a_dst++ = wuffs_base__make_token( *iop_a_dst++ = wuffs_base__make_token(
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | (((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT)); (((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
v_expect = 3762; v_expect = 7858;
goto label__outer__continue; goto label__outer__continue;
} else if (v_class == 4) { } else if (v_class == 4) {
while (true) { while (true) {
@@ -21399,8 +21399,8 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
(((uint64_t)(v_vminor)) (((uint64_t)(v_vminor))
<< WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT)); (((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
v_expect = 66; v_expect = 4162;
v_expect_after_value = 68; v_expect_after_value = 4164;
goto label__outer__continue; goto label__outer__continue;
} else if (v_class == 6) { } else if (v_class == 6) {
(iop_a_src += 1, wuffs_base__make_empty_struct()); (iop_a_src += 1, wuffs_base__make_empty_struct());
@@ -21420,15 +21420,15 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
(((uint64_t)(2105410)) (((uint64_t)(2105410))
<< WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT)); (((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
v_expect = 260; v_expect = 4356;
v_expect_after_value = 260; v_expect_after_value = 4356;
} else { } else {
*iop_a_dst++ = wuffs_base__make_token( *iop_a_dst++ = wuffs_base__make_token(
(((uint64_t)(2113602)) (((uint64_t)(2113602))
<< WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT)); (((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
v_expect = 68; v_expect = 4164;
v_expect_after_value = 68; v_expect_after_value = 4164;
} }
goto label__outer__continue; goto label__outer__continue;
} else if (v_class == 7) { } else if (v_class == 7) {
@@ -21454,8 +21454,8 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
(((uint64_t)(v_vminor)) (((uint64_t)(v_vminor))
<< WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT)); (((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
v_expect = 4018; v_expect = 8114;
v_expect_after_value = 260; v_expect_after_value = 4356;
goto label__outer__continue; goto label__outer__continue;
} else if (v_class == 8) { } else if (v_class == 8) {
(iop_a_src += 1, wuffs_base__make_empty_struct()); (iop_a_src += 1, wuffs_base__make_empty_struct());
@@ -21475,15 +21475,15 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
(((uint64_t)(2105378)) (((uint64_t)(2105378))
<< WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT)); (((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
v_expect = 260; v_expect = 4356;
v_expect_after_value = 260; v_expect_after_value = 4356;
} else { } else {
*iop_a_dst++ = wuffs_base__make_token( *iop_a_dst++ = wuffs_base__make_token(
(((uint64_t)(2113570)) (((uint64_t)(2113570))
<< WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) | << WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT)); (((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
v_expect = 68; v_expect = 4164;
v_expect_after_value = 68; v_expect_after_value = 4164;
} }
goto label__outer__continue; goto label__outer__continue;
} else if (v_class == 9) { } else if (v_class == 9) {
+13 -10
View File
@@ -197,7 +197,7 @@ pri const lut_chars array[256] base.u8 = [
// - 0x09 (bitmask 0x0200) is CLASS_FALSE. // - 0x09 (bitmask 0x0200) is CLASS_FALSE.
// - 0x0A (bitmask 0x0400) is CLASS_TRUE. // - 0x0A (bitmask 0x0400) is CLASS_TRUE.
// - 0x0B (bitmask 0x0800) is CLASS_NULL. // - 0x0B (bitmask 0x0800) is CLASS_NULL.
// - 0x0C (bitmask 0x1000) is reserved. // - 0x0C (bitmask 0x1000) is CLASS_COMMENT.
// - 0x0D (bitmask 0x2000) is reserved. // - 0x0D (bitmask 0x2000) is reserved.
// - 0x0E (bitmask 0x4000) is reserved. // - 0x0E (bitmask 0x4000) is reserved.
// - 0x0F (bitmask 0x8000) is CLASS_BAD_INPUT. // - 0x0F (bitmask 0x8000) is CLASS_BAD_INPUT.
@@ -205,26 +205,29 @@ pri const lut_chars array[256] base.u8 = [
// The bitmasks are used by the "expect" variable: what the next character // The bitmasks are used by the "expect" variable: what the next character
// class can be. // class can be.
// //
// - 0x0002 is EXPECT_STRING. // - 0x1002 is EXPECT_STRING.
// - 0x0EB0 is EXPECT_NON_STRING_VALUE. // - 0x1EB0 is EXPECT_NON_STRING_VALUE.
// - 0x0004 is EXPECT_COMMA. // - 0x1004 is EXPECT_COMMA.
// - 0x0008 is EXPECT_COLON. // - 0x1008 is EXPECT_COLON.
// - 0x0040 is EXPECT_CLOSE_CURLY_BRACE. // - 0x1040 is EXPECT_CLOSE_CURLY_BRACE.
// - 0x0100 is EXPECT_CLOSE_SQUARE_BRACKET. // - 0x1100 is EXPECT_CLOSE_SQUARE_BRACKET.
// //
// Bitwise or'ing these together gives 0x0FFE. Whitespace is never expected, as // Bitwise or'ing these together gives 0x0FFE. Whitespace is never expected, as
// it is handled separately. // it is handled separately.
// //
// EXPECT_VALUE is also defined to be 0x0EB2, equivalent to (EXPECT_STRING | // EXPECT_VALUE is also defined to be 0x1EB2, equivalent to (EXPECT_STRING |
// EXPECT_NON_STRING_VALUE). // EXPECT_NON_STRING_VALUE).
// //
// EXPECT_NUMBER is also defined to be 0x0010. Testing for EXPECT_NUMBER's // EXPECT_NUMBER is also defined to be 0x1010. Testing for EXPECT_NUMBER's
// presence is equivalent to testing for EXPECT_NON_STRING_VALUE. // presence is equivalent to testing for EXPECT_NON_STRING_VALUE.
// //
// "Non-string value" includes literals (false, true, null), numbers, arrays // "Non-string value" includes literals (false, true, null), numbers, arrays
// and objects. // and objects.
// //
// "String value" includes "this" and "th\u0061t". // "String value" includes "this" and "th\u0061t".
//
// Comments are always expected. Whether the relevant quirks are enabled are
// checked elsewhere.
pri const lut_classes array[256] base.u8[..= 0x0F] = [ pri const lut_classes array[256] base.u8[..= 0x0F] = [
// 0 1 2 3 4 5 6 7 // 0 1 2 3 4 5 6 7
// 8 9 A B C D E F // 8 9 A B C D E F
@@ -233,7 +236,7 @@ pri const lut_classes array[256] base.u8[..= 0x0F] = [
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x10 ..= 0x17. 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x10 ..= 0x17.
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x18 ..= 0x1F. 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x18 ..= 0x1F.
0x00, 0x0F, 0x01, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x20 ..= 0x27. ' ', '"'. 0x00, 0x0F, 0x01, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x20 ..= 0x27. ' ', '"'.
0x0F, 0x0F, 0x0F, 0x0F, 0x02, 0x04, 0x0F, 0x0F, // 0x28 ..= 0x2F. ',', '-'. 0x0F, 0x0F, 0x0F, 0x0F, 0x02, 0x04, 0x0F, 0x0C, // 0x28 ..= 0x2F. ',', '-', '/'.
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, // 0x30 ..= 0x37. '0'-'7'. 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, // 0x30 ..= 0x37. '0'-'7'.
0x04, 0x04, 0x03, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x38 ..= 0x3F. '8'-'9', ':'. 0x04, 0x04, 0x03, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, // 0x38 ..= 0x3F. '8'-'9', ':'.
+25 -25
View File
@@ -148,7 +148,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
this.decode_leading?(dst: args.dst, src: args.src) this.decode_leading?(dst: args.dst, src: args.src)
} }
expect = 0x0EB2 // EXPECT_VALUE expect = 0x1EB2 // EXPECT_VALUE
while.outer true { while.outer true {
while.goto_parsed_a_leaf_value true { while.goto_parsed_a_leaf_value true {
@@ -814,8 +814,8 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
// As above, expect must have contained EXPECT_STRING. If it // As above, expect must have contained EXPECT_STRING. If it
// didn't also contain EXPECT_NUMBER then we were parsing an // didn't also contain EXPECT_NUMBER then we were parsing an
// object key and the next token should be ':'. // object key and the next token should be ':'.
if 0 == (expect & 0x0010) { // 0x0010 is EXPECT_NUMBER. if 0 == (expect & 0x0010) { // 0x0010 is (1 << CLASS_NUMBER).
expect = 0x0008 // 0x0008 is EXPECT_COLON. expect = 0x1008 // 0x1008 is EXPECT_COLON.
continue.outer continue.outer
} }
break.goto_parsed_a_leaf_value break.goto_parsed_a_leaf_value
@@ -831,10 +831,10 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
length: 1) length: 1)
// What's valid after a comma depends on whether or not we're // What's valid after a comma depends on whether or not we're
// in an array or an object. // in an array or an object.
if 0 == (expect & 0x0100) { // 0x0100 is EXPECT_CLOSE_SQUARE_BRACKET if 0 == (expect & 0x0100) { // 0x0100 is (1 << CLASS_CLOSE_SQUARE_BRACKET).
expect = 0x0002 // 0x0002 is EXPECT_STRING. expect = 0x1002 // 0x1002 is EXPECT_STRING.
} else { } else {
expect = 0x0EB2 // 0x0EB2 is EXPECT_VALUE. expect = 0x1EB2 // 0x0EB2 is EXPECT_VALUE.
} }
continue.outer continue.outer
@@ -846,7 +846,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
value_minor: 0, value_minor: 0,
link: 0x0, link: 0x0,
length: 1) length: 1)
expect = 0x0EB2 // 0x0EB2 is EXPECT_VALUE. expect = 0x1EB2 // 0x1EB2 is EXPECT_VALUE.
continue.outer continue.outer
} else if class == 0x04 { // 0x04 is CLASS_NUMBER. } else if class == 0x04 { // 0x04 is CLASS_NUMBER.
@@ -899,7 +899,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
vminor = 0x20_4011 vminor = 0x20_4011
if depth == 0 { if depth == 0 {
// No-op. // No-op.
} else if 0 <> (expect_after_value & 0x0040) { // 0x0040 is EXPECT_CLOSE_CURLY_BRACE. } else if 0 <> (expect_after_value & 0x0040) { // 0x0040 is (1 << CLASS_CLOSE_CURLY_BRACE).
vminor = 0x20_4041 vminor = 0x20_4041
} else { } else {
vminor = 0x20_4021 vminor = 0x20_4021
@@ -918,8 +918,8 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
value_minor: vminor, value_minor: vminor,
link: 0x0, link: 0x0,
length: 1) length: 1)
expect = 0x0042 // 0x0042 is (EXPECT_CLOSE_CURLY_BRACE | EXPECT_STRING). expect = 0x1042 // 0x1042 is (EXPECT_CLOSE_CURLY_BRACE | EXPECT_STRING).
expect_after_value = 0x0044 // 0x0044 is (EXPECT_CURLY_CLOSE_BRACE | EXPECT_COMMA). expect_after_value = 0x1044 // 0x1044 is (EXPECT_CURLY_CLOSE_BRACE | EXPECT_COMMA).
continue.outer continue.outer
} else if class == 0x06 { // 0x06 is CLASS_CLOSE_CURLY_BRACE. } else if class == 0x06 { // 0x06 is CLASS_CLOSE_CURLY_BRACE.
@@ -941,18 +941,18 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
value_minor: 0x20_2042, value_minor: 0x20_2042,
link: 0x0, link: 0x0,
length: 1) length: 1)
// 0x0104 is (EXPECT_SQUARE_CLOSE_BRACKET | EXPECT_COMMA). // 0x1104 is (EXPECT_SQUARE_CLOSE_BRACKET | EXPECT_COMMA).
expect = 0x0104 expect = 0x1104
expect_after_value = 0x0104 expect_after_value = 0x1104
} else { } else {
args.dst.write_fast_token!( args.dst.write_fast_token!(
value_major: 0, value_major: 0,
value_minor: 0x20_4042, value_minor: 0x20_4042,
link: 0x0, link: 0x0,
length: 1) length: 1)
// 0x0044 is (EXPECT_CURLY_CLOSE_BRACE | EXPECT_COMMA). // 0x1044 is (EXPECT_CURLY_CLOSE_BRACE | EXPECT_COMMA).
expect = 0x0044 expect = 0x1044
expect_after_value = 0x0044 expect_after_value = 0x1044
} }
continue.outer continue.outer
@@ -960,7 +960,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
vminor = 0x20_2011 vminor = 0x20_2011
if depth == 0 { if depth == 0 {
// No-op. // No-op.
} else if 0 <> (expect_after_value & 0x0040) { // 0x0040 is EXPECT_CLOSE_CURLY_BRACE. } else if 0 <> (expect_after_value & 0x0040) { // 0x0040 is (1 << CLASS_CLOSE_CURLY_BRACE).
vminor = 0x20_2041 vminor = 0x20_2041
} else { } else {
vminor = 0x20_2021 vminor = 0x20_2021
@@ -979,8 +979,8 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
value_minor: vminor, value_minor: vminor,
link: 0x0, link: 0x0,
length: 1) length: 1)
expect = 0x0FB2 // 0x0FB2 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_VALUE). expect = 0x1FB2 // 0x1FB2 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_VALUE).
expect_after_value = 0x0104 // 0x0104 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_COMMA). expect_after_value = 0x1104 // 0x1104 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_COMMA).
continue.outer continue.outer
} else if class == 0x08 { // 0x08 is CLASS_CLOSE_SQUARE_BRACKET. } else if class == 0x08 { // 0x08 is CLASS_CLOSE_SQUARE_BRACKET.
@@ -1002,18 +1002,18 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
value_minor: 0x20_2022, value_minor: 0x20_2022,
link: 0x0, link: 0x0,
length: 1) length: 1)
// 0x0104 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_COMMA). // 0x1104 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_COMMA).
expect = 0x0104 expect = 0x1104
expect_after_value = 0x0104 expect_after_value = 0x1104
} else { } else {
args.dst.write_fast_token!( args.dst.write_fast_token!(
value_major: 0, value_major: 0,
value_minor: 0x20_4022, value_minor: 0x20_4022,
link: 0x0, link: 0x0,
length: 1) length: 1)
// 0x0044 is (EXPECT_CLOSE_CURLY_BRACE | EXPECT_COMMA). // 0x1044 is (EXPECT_CLOSE_CURLY_BRACE | EXPECT_COMMA).
expect = 0x0044 expect = 0x1044
expect_after_value = 0x0044 expect_after_value = 0x1044
} }
continue.outer continue.outer