mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 09:01:35 +01:00
Add a "while.goto_foo true { etc }" to std/json
This commit is contained in:
1 parent
c92c0f50e4
commit
93b09674a9
2 files changed
+125
-61
No files matched your search
@@ -18584,6 +18584,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
|
|
||||||
v_expect = 3;
|
v_expect = 3;
|
||||||
label_0_continue:;
|
label_0_continue:;
|
||||||
|
while (true) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||||
@@ -18605,7 +18606,8 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
status =
|
||||||
|
wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||||
v_whitespace_length = 0;
|
v_whitespace_length = 0;
|
||||||
goto label_0_continue;
|
goto label_0_continue;
|
||||||
@@ -18657,8 +18659,8 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
label_2_continue:;
|
label_2_continue:;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||||
status =
|
status = wuffs_base__make_status(
|
||||||
wuffs_base__make_status(wuffs_base__suspension__short_write);
|
wuffs_base__suspension__short_write);
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||||
goto label_2_continue;
|
goto label_2_continue;
|
||||||
}
|
}
|
||||||
@@ -18678,8 +18680,8 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
wuffs_base__make_status(wuffs_json__error__bad_input);
|
wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
status =
|
status = wuffs_base__make_status(
|
||||||
wuffs_base__make_status(wuffs_base__suspension__short_read);
|
wuffs_base__suspension__short_read);
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||||
v_string_length = 0;
|
v_string_length = 0;
|
||||||
goto label_2_continue;
|
goto label_2_continue;
|
||||||
@@ -18709,13 +18711,16 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
} else if (v_c == 92) {
|
} else if (v_c == 92) {
|
||||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
status =
|
||||||
|
wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (v_string_length >= 65534) {
|
if (v_string_length >= 65534) {
|
||||||
*iop_a_dst++ = wuffs_base__make_token(
|
*iop_a_dst++ = wuffs_base__make_token(
|
||||||
(((uint64_t)(6291457)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
(((uint64_t)(6291457))
|
||||||
(((uint64_t)(65535)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||||
|
(((uint64_t)(65535))
|
||||||
|
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||||
v_string_length = 0;
|
v_string_length = 0;
|
||||||
goto label_2_continue;
|
goto label_2_continue;
|
||||||
}
|
}
|
||||||
@@ -18739,6 +18744,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
v_expect = 8;
|
v_expect = 8;
|
||||||
goto label_0_continue;
|
goto label_0_continue;
|
||||||
}
|
}
|
||||||
|
goto label_4_break;
|
||||||
} else if (v_c == 44) {
|
} else if (v_c == 44) {
|
||||||
if (0 == (v_expect & 4)) {
|
if (0 == (v_expect & 4)) {
|
||||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||||
@@ -18779,7 +18785,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||||
(((uint64_t)(((uint64_t)(v_number_length))))
|
(((uint64_t)(((uint64_t)(v_number_length))))
|
||||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||||
goto label_4_break;
|
goto label_5_break;
|
||||||
}
|
}
|
||||||
while (v_number_length > 0) {
|
while (v_number_length > 0) {
|
||||||
v_number_length -= 1;
|
v_number_length -= 1;
|
||||||
@@ -18809,10 +18815,8 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
label_4_break:;
|
label_5_break:;
|
||||||
} else {
|
goto label_4_break;
|
||||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
} else if (v_c == 58) {
|
} else if (v_c == 58) {
|
||||||
if (0 == (v_expect & 8)) {
|
if (0 == (v_expect & 8)) {
|
||||||
@@ -18936,8 +18940,8 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
}
|
}
|
||||||
v_match = 2;
|
v_match = 2;
|
||||||
if (v_c == 110) {
|
if (v_c == 110) {
|
||||||
v_match =
|
v_match = wuffs_base__io_reader__match7(iop_a_src, io2_a_src,
|
||||||
wuffs_base__io_reader__match7(iop_a_src, io2_a_src, 465676103172);
|
465676103172);
|
||||||
if (v_match == 0) {
|
if (v_match == 0) {
|
||||||
*iop_a_dst++ = wuffs_base__make_token(
|
*iop_a_dst++ = wuffs_base__make_token(
|
||||||
(((uint64_t)(4194337)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
(((uint64_t)(4194337)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||||
@@ -18948,6 +18952,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
(iop_a_src += 4, wuffs_base__make_empty_struct());
|
(iop_a_src += 4, wuffs_base__make_empty_struct());
|
||||||
|
goto label_4_break;
|
||||||
}
|
}
|
||||||
} else if (v_c == 102) {
|
} else if (v_c == 102) {
|
||||||
v_match = wuffs_base__io_reader__match7(iop_a_src, io2_a_src,
|
v_match = wuffs_base__io_reader__match7(iop_a_src, io2_a_src,
|
||||||
@@ -18962,10 +18967,11 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
(iop_a_src += 5, wuffs_base__make_empty_struct());
|
(iop_a_src += 5, wuffs_base__make_empty_struct());
|
||||||
|
goto label_4_break;
|
||||||
}
|
}
|
||||||
} else if (v_c == 116) {
|
} else if (v_c == 116) {
|
||||||
v_match =
|
v_match = wuffs_base__io_reader__match7(iop_a_src, io2_a_src,
|
||||||
wuffs_base__io_reader__match7(iop_a_src, io2_a_src, 435762131972);
|
435762131972);
|
||||||
if (v_match == 0) {
|
if (v_match == 0) {
|
||||||
*iop_a_dst++ = wuffs_base__make_token(
|
*iop_a_dst++ = wuffs_base__make_token(
|
||||||
(((uint64_t)(4194433)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
(((uint64_t)(4194433)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||||
@@ -18976,17 +18982,20 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
(iop_a_src += 4, wuffs_base__make_empty_struct());
|
(iop_a_src += 4, wuffs_base__make_empty_struct());
|
||||||
|
goto label_4_break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (v_match == 1) {
|
if (v_match == 1) {
|
||||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
status =
|
||||||
|
wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||||
goto label_0_continue;
|
goto label_0_continue;
|
||||||
} else if (v_match == 2) {
|
}
|
||||||
|
}
|
||||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
label_4_break:;
|
||||||
if (v_depth == 0) {
|
if (v_depth == 0) {
|
||||||
goto label_0_break;
|
goto label_0_break;
|
||||||
}
|
}
|
||||||
|
|||||||
+96
-41
@@ -89,6 +89,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
expect = 0x03 // EXPECT_VALUE
|
expect = 0x03 // EXPECT_VALUE
|
||||||
|
|
||||||
while.outer true {
|
while.outer true {
|
||||||
|
while.goto_parsed_a_leaf_value true {
|
||||||
if args.dst.available() <= 0 {
|
if args.dst.available() <= 0 {
|
||||||
yield? base."$short write"
|
yield? base."$short write"
|
||||||
continue.outer
|
continue.outer
|
||||||
@@ -103,7 +104,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
{
|
{
|
||||||
if args.src.available() <= 0 {
|
if args.src.available() <= 0 {
|
||||||
if whitespace_length > 0 {
|
if whitespace_length > 0 {
|
||||||
args.dst.write_fast_token!(value: 0, length: whitespace_length as base.u64)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0,
|
||||||
|
length: whitespace_length as base.u64)
|
||||||
whitespace_length = 0
|
whitespace_length = 0
|
||||||
}
|
}
|
||||||
if args.src.is_closed() {
|
if args.src.is_closed() {
|
||||||
@@ -119,14 +122,18 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
break.ws
|
break.ws
|
||||||
} else if (c <> 0x20) and (c <> 0x0A) and (c <> 0x09) and (c <> 0x0D) {
|
} else if (c <> 0x20) and (c <> 0x0A) and (c <> 0x09) and (c <> 0x0D) {
|
||||||
if whitespace_length > 0 {
|
if whitespace_length > 0 {
|
||||||
args.dst.write_fast_token!(value: 0, length: whitespace_length as base.u64)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0,
|
||||||
|
length: whitespace_length as base.u64)
|
||||||
}
|
}
|
||||||
return "#bad input"
|
return "#bad input"
|
||||||
}
|
}
|
||||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||||
|
|
||||||
if whitespace_length >= 0xFFFE {
|
if whitespace_length >= 0xFFFE {
|
||||||
args.dst.write_fast_token!(value: 0, length: 0xFFFF)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0,
|
||||||
|
length: 0xFFFF)
|
||||||
whitespace_length = 0
|
whitespace_length = 0
|
||||||
continue.outer
|
continue.outer
|
||||||
}
|
}
|
||||||
@@ -135,17 +142,19 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
|
|
||||||
// Emit whitespace.
|
// Emit whitespace.
|
||||||
if whitespace_length > 0 {
|
if whitespace_length > 0 {
|
||||||
args.dst.write_fast_token!(value: 0, length: whitespace_length as base.u64)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0,
|
||||||
|
length: whitespace_length as base.u64)
|
||||||
whitespace_length = 0
|
whitespace_length = 0
|
||||||
if args.dst.available() <= 0 {
|
if args.dst.available() <= 0 {
|
||||||
continue.outer
|
continue.outer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// These assertions are redundant (the Wuffs compiler should already
|
// These assertions are redundant (the Wuffs compiler should
|
||||||
// know these facts; deleting these assertions should still compile)
|
// already know these facts; deleting these assertions should still
|
||||||
// but are listed explicitly to help guard against future edits to the
|
// compile) but are listed explicitly to guard against future edits
|
||||||
// code above inadvertently invalidating these assertions.
|
// to the code above inadvertently invalidating these assertions.
|
||||||
assert args.dst.available() > 0
|
assert args.dst.available() > 0
|
||||||
assert args.src.available() > 0
|
assert args.src.available() > 0
|
||||||
|
|
||||||
@@ -157,7 +166,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The leading '"' is filler.
|
// The leading '"' is filler.
|
||||||
args.dst.write_fast_token!(value: 0, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0,
|
||||||
|
length: 1)
|
||||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||||
|
|
||||||
while.string_loop true {
|
while.string_loop true {
|
||||||
@@ -172,7 +183,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
{
|
{
|
||||||
if args.src.available() <= 0 {
|
if args.src.available() <= 0 {
|
||||||
if string_length > 0 {
|
if string_length > 0 {
|
||||||
args.dst.write_fast_token!(value: 0x60_0001, length: string_length as base.u64)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x60_0001,
|
||||||
|
length: string_length as base.u64)
|
||||||
string_length = 0
|
string_length = 0
|
||||||
}
|
}
|
||||||
if args.src.is_closed() {
|
if args.src.is_closed() {
|
||||||
@@ -187,13 +200,17 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
|
|
||||||
if c <= 0x22 { // 0x22 is '"'.
|
if c <= 0x22 { // 0x22 is '"'.
|
||||||
if c == 0x22 { // 0x22 is '"'.
|
if c == 0x22 { // 0x22 is '"'.
|
||||||
args.dst.write_fast_token!(value: 0x60_0000, length: string_length as base.u64)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x60_0000,
|
||||||
|
length: string_length as base.u64)
|
||||||
string_length = 0
|
string_length = 0
|
||||||
break.string_loop
|
break.string_loop
|
||||||
|
|
||||||
} else if c < 0x20 { // 0x20 is ' '.
|
} else if c < 0x20 { // 0x20 is ' '.
|
||||||
if string_length > 0 {
|
if string_length > 0 {
|
||||||
args.dst.write_fast_token!(value: 0x60_0001, length: string_length as base.u64)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x60_0001,
|
||||||
|
length: string_length as base.u64)
|
||||||
string_length = 0
|
string_length = 0
|
||||||
}
|
}
|
||||||
return "#bad input"
|
return "#bad input"
|
||||||
@@ -206,7 +223,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if string_length >= 0xFFFE {
|
if string_length >= 0xFFFE {
|
||||||
args.dst.write_fast_token!(value: 0x60_0001, length: 0xFFFF)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x60_0001,
|
||||||
|
length: 0xFFFF)
|
||||||
string_length = 0
|
string_length = 0
|
||||||
continue.string_loop
|
continue.string_loop
|
||||||
}
|
}
|
||||||
@@ -217,20 +236,23 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
// The trailing '"' is filler.
|
// The trailing '"' is filler.
|
||||||
while true {
|
while true {
|
||||||
if args.dst.available() > 0 {
|
if args.dst.available() > 0 {
|
||||||
args.dst.write_fast_token!(value: 0, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0,
|
||||||
|
length: 1)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
yield? base."$short write"
|
yield? base."$short write"
|
||||||
}
|
}
|
||||||
|
|
||||||
// As above, expect must have contained EXPECT_STRING_VALUE. If
|
// As above, expect must have contained
|
||||||
// it didn't also contain EXPECT_NON_STRING_VALUE then we were
|
// EXPECT_STRING_VALUE. If it didn't also contain
|
||||||
// parsing an object key and the next token should be ':'.
|
// EXPECT_NON_STRING_VALUE then we were parsing an object
|
||||||
// Otherwise, fall below to "We've just parsed a value".
|
// key and the next token should be ':'.
|
||||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||||
expect = 0x08 // 0x08 is EXPECT_COLON.
|
expect = 0x08 // 0x08 is EXPECT_COLON.
|
||||||
continue.outer
|
continue.outer
|
||||||
}
|
}
|
||||||
|
break.goto_parsed_a_leaf_value
|
||||||
// -------- END parse strings.
|
// -------- END parse strings.
|
||||||
|
|
||||||
} else if c == 0x2C { // 0x2C is ','.
|
} else if c == 0x2C { // 0x2C is ','.
|
||||||
@@ -238,9 +260,12 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
return "#bad input"
|
return "#bad input"
|
||||||
}
|
}
|
||||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||||
args.dst.write_fast_token!(value: 0, length: 1) // The ',' is filler.
|
// The ',' is filler.
|
||||||
// What's valid after a comma depends on whether or not we're
|
args.dst.write_fast_token!(
|
||||||
// in an array or an object.
|
value: 0,
|
||||||
|
length: 1)
|
||||||
|
// What's valid after a comma depends on whether or not
|
||||||
|
// we're in an array or an object.
|
||||||
if 0 == (expect & 0x10) { // 0x10 is EXPECT_CLOSE_BRACKET
|
if 0 == (expect & 0x10) { // 0x10 is EXPECT_CLOSE_BRACKET
|
||||||
expect = 0x02 // 0x02 is EXPECT_STRING_VALUE.
|
expect = 0x02 // 0x02 is EXPECT_STRING_VALUE.
|
||||||
} else {
|
} else {
|
||||||
@@ -264,7 +289,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
}
|
}
|
||||||
number_length = number_length & 0x7F
|
number_length = number_length & 0x7F
|
||||||
if number_status == 0 {
|
if number_status == 0 {
|
||||||
args.dst.write_fast_token!(value: token_value, length: number_length as base.u64)
|
args.dst.write_fast_token!(
|
||||||
|
value: token_value,
|
||||||
|
length: number_length as base.u64)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,10 +317,8 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break.goto_parsed_a_leaf_value
|
||||||
// -------- END parse numbers.
|
// -------- END parse numbers.
|
||||||
|
|
||||||
} else {
|
|
||||||
return "#bad input"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if c == 0x3A { // 0x3A is ':'.
|
} else if c == 0x3A { // 0x3A is ':'.
|
||||||
@@ -301,7 +326,10 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
return "#bad input"
|
return "#bad input"
|
||||||
}
|
}
|
||||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||||
args.dst.write_fast_token!(value: 0, length: 1) // The ':' is filler.
|
// The ':' is filler.
|
||||||
|
args.dst.write_fast_token!(
|
||||||
|
value: 0,
|
||||||
|
length: 1)
|
||||||
expect = 0x03 // 0x03 is EXPECT_VALUE.
|
expect = 0x03 // 0x03 is EXPECT_VALUE.
|
||||||
continue.outer
|
continue.outer
|
||||||
|
|
||||||
@@ -318,7 +346,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
depth += 1
|
depth += 1
|
||||||
|
|
||||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||||
args.dst.write_fast_token!(value: 0x20_0011, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x20_0011,
|
||||||
|
length: 1)
|
||||||
expect = 0x13 // 0x13 is (EXPECT_CLOSE_BRACKET | EXPECT_VALUE).
|
expect = 0x13 // 0x13 is (EXPECT_CLOSE_BRACKET | EXPECT_VALUE).
|
||||||
expect_after_value = 0x14 // 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
|
expect_after_value = 0x14 // 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
|
||||||
continue.outer
|
continue.outer
|
||||||
@@ -329,19 +359,25 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
}
|
}
|
||||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||||
if depth <= 1 {
|
if depth <= 1 {
|
||||||
args.dst.write_fast_token!(value: 0x20_0012, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x20_0012,
|
||||||
|
length: 1)
|
||||||
break.outer
|
break.outer
|
||||||
}
|
}
|
||||||
depth -= 1
|
depth -= 1
|
||||||
stack_byte = (depth - 1) / 32
|
stack_byte = (depth - 1) / 32
|
||||||
stack_bit = (depth - 1) & 31
|
stack_bit = (depth - 1) & 31
|
||||||
if 0 == (this.stack[stack_byte] & ((1 as base.u32) << stack_bit)) {
|
if 0 == (this.stack[stack_byte] & ((1 as base.u32) << stack_bit)) {
|
||||||
args.dst.write_fast_token!(value: 0x20_1012, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x20_1012,
|
||||||
|
length: 1)
|
||||||
// 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
|
// 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
|
||||||
expect = 0x14
|
expect = 0x14
|
||||||
expect_after_value = 0x14
|
expect_after_value = 0x14
|
||||||
} else {
|
} else {
|
||||||
args.dst.write_fast_token!(value: 0x20_2012, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x20_2012,
|
||||||
|
length: 1)
|
||||||
// 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
|
// 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
|
||||||
expect = 0x24
|
expect = 0x24
|
||||||
expect_after_value = 0x24
|
expect_after_value = 0x24
|
||||||
@@ -361,7 +397,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
depth += 1
|
depth += 1
|
||||||
|
|
||||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||||
args.dst.write_fast_token!(value: 0x20_0021, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x20_0021,
|
||||||
|
length: 1)
|
||||||
expect = 0x22 // 0x22 is (EXPECT_CLOSE_BRACE | EXPECT_STRING_VALUE).
|
expect = 0x22 // 0x22 is (EXPECT_CLOSE_BRACE | EXPECT_STRING_VALUE).
|
||||||
expect_after_value = 0x24 // 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
|
expect_after_value = 0x24 // 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
|
||||||
continue.outer
|
continue.outer
|
||||||
@@ -372,19 +410,25 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
}
|
}
|
||||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||||
if depth <= 1 {
|
if depth <= 1 {
|
||||||
args.dst.write_fast_token!(value: 0x20_0022, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x20_0022,
|
||||||
|
length: 1)
|
||||||
break.outer
|
break.outer
|
||||||
}
|
}
|
||||||
depth -= 1
|
depth -= 1
|
||||||
stack_byte = (depth - 1) / 32
|
stack_byte = (depth - 1) / 32
|
||||||
stack_bit = (depth - 1) & 31
|
stack_bit = (depth - 1) & 31
|
||||||
if 0 == (this.stack[stack_byte] & ((1 as base.u32) << stack_bit)) {
|
if 0 == (this.stack[stack_byte] & ((1 as base.u32) << stack_bit)) {
|
||||||
args.dst.write_fast_token!(value: 0x20_1022, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x20_1022,
|
||||||
|
length: 1)
|
||||||
// 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
|
// 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
|
||||||
expect = 0x14
|
expect = 0x14
|
||||||
expect_after_value = 0x14
|
expect_after_value = 0x14
|
||||||
} else {
|
} else {
|
||||||
args.dst.write_fast_token!(value: 0x20_2022, length: 1)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x20_2022,
|
||||||
|
length: 1)
|
||||||
// 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
|
// 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
|
||||||
expect = 0x24
|
expect = 0x24
|
||||||
expect_after_value = 0x24
|
expect_after_value = 0x24
|
||||||
@@ -399,31 +443,40 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
if c == 0x6E { // 0x6E is 'n'.
|
if c == 0x6E { // 0x6E is 'n'.
|
||||||
match = args.src.match7(a: 0x6C_6C75_6E04) // 4 bytes "null".
|
match = args.src.match7(a: 0x6C_6C75_6E04) // 4 bytes "null".
|
||||||
if match == 0 {
|
if match == 0 {
|
||||||
args.dst.write_fast_token!(value: 0x40_0021, length: 4)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x40_0021,
|
||||||
|
length: 4)
|
||||||
if args.src.available() < 4 {
|
if args.src.available() < 4 {
|
||||||
return "#internal error: inconsistent I/O"
|
return "#internal error: inconsistent I/O"
|
||||||
}
|
}
|
||||||
args.src.skip32_fast!(actual: 4, worst_case: 4)
|
args.src.skip32_fast!(actual: 4, worst_case: 4)
|
||||||
|
break.goto_parsed_a_leaf_value
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if c == 0x66 { // 0x66 is 'f'.
|
} else if c == 0x66 { // 0x66 is 'f'.
|
||||||
match = args.src.match7(a: 0x6573_6C61_6605) // 5 bytes "false".
|
match = args.src.match7(a: 0x6573_6C61_6605) // 5 bytes "false".
|
||||||
if match == 0 {
|
if match == 0 {
|
||||||
args.dst.write_fast_token!(value: 0x40_0041, length: 5)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x40_0041,
|
||||||
|
length: 5)
|
||||||
if args.src.available() < 5 {
|
if args.src.available() < 5 {
|
||||||
return "#internal error: inconsistent I/O"
|
return "#internal error: inconsistent I/O"
|
||||||
}
|
}
|
||||||
args.src.skip32_fast!(actual: 5, worst_case: 5)
|
args.src.skip32_fast!(actual: 5, worst_case: 5)
|
||||||
|
break.goto_parsed_a_leaf_value
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if c == 0x74 { // 0x74 is 't'.
|
} else if c == 0x74 { // 0x74 is 't'.
|
||||||
match = args.src.match7(a: 0x65_7572_7404) // 4 bytes "true".
|
match = args.src.match7(a: 0x65_7572_7404) // 4 bytes "true".
|
||||||
if match == 0 {
|
if match == 0 {
|
||||||
args.dst.write_fast_token!(value: 0x40_0081, length: 4)
|
args.dst.write_fast_token!(
|
||||||
|
value: 0x40_0081,
|
||||||
|
length: 4)
|
||||||
if args.src.available() < 4 {
|
if args.src.available() < 4 {
|
||||||
return "#internal error: inconsistent I/O"
|
return "#internal error: inconsistent I/O"
|
||||||
}
|
}
|
||||||
args.src.skip32_fast!(actual: 4, worst_case: 4)
|
args.src.skip32_fast!(actual: 4, worst_case: 4)
|
||||||
|
break.goto_parsed_a_leaf_value
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -431,17 +484,19 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
|||||||
if match == 1 {
|
if match == 1 {
|
||||||
yield? base."$short read"
|
yield? base."$short read"
|
||||||
continue.outer
|
continue.outer
|
||||||
} else if match == 2 {
|
|
||||||
return "#bad input"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've just parsed a value.
|
return "#bad input"
|
||||||
|
} // while.goto_parsed_a_leaf_value
|
||||||
|
|
||||||
|
// We've just parsed a leaf (non-container) value: literal (null,
|
||||||
|
// false, true), number or string.
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
break.outer
|
break.outer
|
||||||
}
|
}
|
||||||
expect = expect_after_value
|
expect = expect_after_value
|
||||||
}
|
} // while.outer
|
||||||
}
|
}
|
||||||
|
|
||||||
pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||||
|
|||||||
Reference in new issue
Block a user