Have std/json decode ']' and '}'

This commit is contained in:
Nigel Tao committed 2020-02-16 22:19:12 +11:00
1 parent 40778f0665
commit 293e9a8928
2 files changed
+95 -1

No files matched your search

+48
View File
@@ -18447,6 +18447,30 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
v_expect = 19;
v_expect_after_value = 20;
goto label_0_continue;
} else if (v_c == 93) {
if (0 == (v_expect & 16)) {
status = wuffs_base__make_status(wuffs_json__error__bad_input);
goto exit;
}
(iop_a_src += 1, wuffs_base__make_empty_struct());
*iop_a_dst++ = wuffs_base__make_token(
(((uint64_t)(2097232)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
if (v_depth <= 1) {
goto label_0_break;
}
v_depth -= 1;
v_stack_byte = ((v_depth - 1) / 32);
v_stack_bit = ((v_depth - 1) & 31);
if (0 == (self->private_data.f_stack[v_stack_byte] &
(((uint32_t)(1)) << v_stack_bit))) {
v_expect = 20;
v_expect_after_value = 20;
} else {
v_expect = 36;
v_expect_after_value = 36;
}
goto label_0_continue;
} else if (v_c == 123) {
if (0 == (v_expect & 1)) {
status = wuffs_base__make_status(wuffs_json__error__bad_input);
@@ -18469,6 +18493,30 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
v_expect = 34;
v_expect_after_value = 36;
goto label_0_continue;
} else if (v_c == 125) {
if (0 == (v_expect & 32)) {
status = wuffs_base__make_status(wuffs_json__error__bad_input);
goto exit;
}
(iop_a_src += 1, wuffs_base__make_empty_struct());
*iop_a_dst++ = wuffs_base__make_token(
(((uint64_t)(2097248)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
if (v_depth <= 1) {
goto label_0_break;
}
v_depth -= 1;
v_stack_byte = ((v_depth - 1) / 32);
v_stack_bit = ((v_depth - 1) & 31);
if (0 == (self->private_data.f_stack[v_stack_byte] &
(((uint32_t)(1)) << v_stack_bit))) {
v_expect = 20;
v_expect_after_value = 20;
} else {
v_expect = 36;
v_expect_after_value = 36;
}
goto label_0_continue;
} else {
status = wuffs_base__make_status(wuffs_json__error__bad_input);
goto exit;
+47 -1
View File
@@ -255,6 +255,29 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
expect_after_value = 0x14 // 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
continue.outer
} else if c == 0x5D { // 0x5D is ']'.
if 0 == (expect & 0x10) { // 0x10 is EXPECT_CLOSE_BRACKET
return "#bad input"
}
args.src.skip32_fast!(actual: 1, worst_case: 1)
args.dst.write_fast_token!(value: 0x20_0050, length: 1)
if depth <= 1 {
break.outer
}
depth -= 1
stack_byte = (depth - 1) / 32
stack_bit = (depth - 1) & 31
if 0 == (this.stack[stack_byte] & ((1 as base.u32) << stack_bit)) {
// 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
expect = 0x14
expect_after_value = 0x14
} else {
// 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
expect = 0x24
expect_after_value = 0x24
}
continue.outer
} else if c == 0x7B { // 0x7B is '{'.
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
return "#bad input"
@@ -270,7 +293,30 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
args.src.skip32_fast!(actual: 1, worst_case: 1)
args.dst.write_fast_token!(value: 0x20_0020, length: 1)
expect = 0x22 // 0x22 is (EXPECT_CLOSE_BRACE | EXPECT_STRING_VALUE).
expect_after_value = 0x24 // 0x14 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
expect_after_value = 0x24 // 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
continue.outer
} else if c == 0x7D { // 0x7D is '}'.
if 0 == (expect & 0x20) { // 0x20 is EXPECT_CLOSE_BRACE.
return "#bad input"
}
args.src.skip32_fast!(actual: 1, worst_case: 1)
args.dst.write_fast_token!(value: 0x20_0060, length: 1)
if depth <= 1 {
break.outer
}
depth -= 1
stack_byte = (depth - 1) / 32
stack_bit = (depth - 1) & 31
if 0 == (this.stack[stack_byte] & ((1 as base.u32) << stack_bit)) {
// 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
expect = 0x14
expect_after_value = 0x14
} else {
// 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
expect = 0x24
expect_after_value = 0x24
}
continue.outer
} else {