authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-12-30 23:13:10+11:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-12-30 23:47:33+11:00
log0def92cff4650f4c06c338182c20558c855b6234
tree73771e40b2eb381baf92dec82bdcf63e57d60847
parent80d37a13c0e2be9aff63745e03ac4fab8f55aa98
signature Commit is signed but in an unrecognized format.

std: use enum literals in std.json


1 files changed, 156 insertions(+), 156 deletions(-)

lib/std/json.zig+156-156
......@@ -84,11 +84,11 @@ pub const StreamingParser = struct {
8484 }
8585
8686 pub fn reset(p: *StreamingParser) void {
87 p.state = State.TopLevelBegin;
87 p.state = .TopLevelBegin;
8888 p.count = 0;
8989 // Set before ever read in main transition function
9090 p.after_string_state = undefined;
91 p.after_value_state = State.ValueEnd; // handle end of values normally
91 p.after_value_state = .ValueEnd; // handle end of values normally
9292 p.stack = 0;
9393 p.stack_used = 0;
9494 p.complete = false;
......@@ -187,14 +187,14 @@ pub const StreamingParser = struct {
187187 // Perform a single transition on the state machine and return any possible token.
188188 fn transition(p: *StreamingParser, c: u8, token: *?Token) Error!bool {
189189 switch (p.state) {
190 State.TopLevelBegin => switch (c) {
190 .TopLevelBegin => switch (c) {
191191 '{' => {
192192 p.stack <<= 1;
193193 p.stack |= object_bit;
194194 p.stack_used += 1;
195195
196 p.state = State.ValueBegin;
197 p.after_string_state = State.ObjectSeparator;
196 p.state = .ValueBegin;
197 p.after_string_state = .ObjectSeparator;
198198
199199 token.* = Token.ObjectBegin;
200200 },
......@@ -203,50 +203,50 @@ pub const StreamingParser = struct {
203203 p.stack |= array_bit;
204204 p.stack_used += 1;
205205
206 p.state = State.ValueBegin;
207 p.after_string_state = State.ValueEnd;
206 p.state = .ValueBegin;
207 p.after_string_state = .ValueEnd;
208208
209209 token.* = Token.ArrayBegin;
210210 },
211211 '-' => {
212212 p.number_is_integer = true;
213 p.state = State.Number;
214 p.after_value_state = State.TopLevelEnd;
213 p.state = .Number;
214 p.after_value_state = .TopLevelEnd;
215215 p.count = 0;
216216 },
217217 '0' => {
218218 p.number_is_integer = true;
219 p.state = State.NumberMaybeDotOrExponent;
220 p.after_value_state = State.TopLevelEnd;
219 p.state = .NumberMaybeDotOrExponent;
220 p.after_value_state = .TopLevelEnd;
221221 p.count = 0;
222222 },
223223 '1'...'9' => {
224224 p.number_is_integer = true;
225 p.state = State.NumberMaybeDigitOrDotOrExponent;
226 p.after_value_state = State.TopLevelEnd;
225 p.state = .NumberMaybeDigitOrDotOrExponent;
226 p.after_value_state = .TopLevelEnd;
227227 p.count = 0;
228228 },
229229 '"' => {
230 p.state = State.String;
231 p.after_value_state = State.TopLevelEnd;
230 p.state = .String;
231 p.after_value_state = .TopLevelEnd;
232232 // We don't actually need the following since after_value_state should override.
233 p.after_string_state = State.ValueEnd;
233 p.after_string_state = .ValueEnd;
234234 p.string_has_escape = false;
235235 p.count = 0;
236236 },
237237 't' => {
238 p.state = State.TrueLiteral1;
239 p.after_value_state = State.TopLevelEnd;
238 p.state = .TrueLiteral1;
239 p.after_value_state = .TopLevelEnd;
240240 p.count = 0;
241241 },
242242 'f' => {
243 p.state = State.FalseLiteral1;
244 p.after_value_state = State.TopLevelEnd;
243 p.state = .FalseLiteral1;
244 p.after_value_state = .TopLevelEnd;
245245 p.count = 0;
246246 },
247247 'n' => {
248 p.state = State.NullLiteral1;
249 p.after_value_state = State.TopLevelEnd;
248 p.state = .NullLiteral1;
249 p.after_value_state = .TopLevelEnd;
250250 p.count = 0;
251251 },
252252 0x09, 0x0A, 0x0D, 0x20 => {
......@@ -257,7 +257,7 @@ pub const StreamingParser = struct {
257257 },
258258 },
259259
260 State.TopLevelEnd => switch (c) {
260 .TopLevelEnd => switch (c) {
261261 0x09, 0x0A, 0x0D, 0x20 => {
262262 // whitespace
263263 },
......@@ -266,7 +266,7 @@ pub const StreamingParser = struct {
266266 },
267267 },
268268
269 State.ValueBegin => switch (c) {
269 .ValueBegin => switch (c) {
270270 // NOTE: These are shared in ValueEnd as well, think we can reorder states to
271271 // be a bit clearer and avoid this duplication.
272272 '}' => {
......@@ -278,7 +278,7 @@ pub const StreamingParser = struct {
278278 return error.TooManyClosingItems;
279279 }
280280
281 p.state = State.ValueBegin;
281 p.state = .ValueBegin;
282282 p.after_string_state = State.fromInt(p.stack & 1);
283283
284284 p.stack >>= 1;
......@@ -287,10 +287,10 @@ pub const StreamingParser = struct {
287287 switch (p.stack_used) {
288288 0 => {
289289 p.complete = true;
290 p.state = State.TopLevelEnd;
290 p.state = .TopLevelEnd;
291291 },
292292 else => {
293 p.state = State.ValueEnd;
293 p.state = .ValueEnd;
294294 },
295295 }
296296
......@@ -304,7 +304,7 @@ pub const StreamingParser = struct {
304304 return error.TooManyClosingItems;
305305 }
306306
307 p.state = State.ValueBegin;
307 p.state = .ValueBegin;
308308 p.after_string_state = State.fromInt(p.stack & 1);
309309
310310 p.stack >>= 1;
......@@ -313,10 +313,10 @@ pub const StreamingParser = struct {
313313 switch (p.stack_used) {
314314 0 => {
315315 p.complete = true;
316 p.state = State.TopLevelEnd;
316 p.state = .TopLevelEnd;
317317 },
318318 else => {
319 p.state = State.ValueEnd;
319 p.state = .ValueEnd;
320320 },
321321 }
322322
......@@ -331,8 +331,8 @@ pub const StreamingParser = struct {
331331 p.stack |= object_bit;
332332 p.stack_used += 1;
333333
334 p.state = State.ValueBegin;
335 p.after_string_state = State.ObjectSeparator;
334 p.state = .ValueBegin;
335 p.after_string_state = .ObjectSeparator;
336336
337337 token.* = Token.ObjectBegin;
338338 },
......@@ -345,40 +345,40 @@ pub const StreamingParser = struct {
345345 p.stack |= array_bit;
346346 p.stack_used += 1;
347347
348 p.state = State.ValueBegin;
349 p.after_string_state = State.ValueEnd;
348 p.state = .ValueBegin;
349 p.after_string_state = .ValueEnd;
350350
351351 token.* = Token.ArrayBegin;
352352 },
353353 '-' => {
354354 p.number_is_integer = true;
355 p.state = State.Number;
355 p.state = .Number;
356356 p.count = 0;
357357 },
358358 '0' => {
359359 p.number_is_integer = true;
360 p.state = State.NumberMaybeDotOrExponent;
360 p.state = .NumberMaybeDotOrExponent;
361361 p.count = 0;
362362 },
363363 '1'...'9' => {
364364 p.number_is_integer = true;
365 p.state = State.NumberMaybeDigitOrDotOrExponent;
365 p.state = .NumberMaybeDigitOrDotOrExponent;
366366 p.count = 0;
367367 },
368368 '"' => {
369 p.state = State.String;
369 p.state = .String;
370370 p.count = 0;
371371 },
372372 't' => {
373 p.state = State.TrueLiteral1;
373 p.state = .TrueLiteral1;
374374 p.count = 0;
375375 },
376376 'f' => {
377 p.state = State.FalseLiteral1;
377 p.state = .FalseLiteral1;
378378 p.count = 0;
379379 },
380380 'n' => {
381 p.state = State.NullLiteral1;
381 p.state = .NullLiteral1;
382382 p.count = 0;
383383 },
384384 0x09, 0x0A, 0x0D, 0x20 => {
......@@ -390,7 +390,7 @@ pub const StreamingParser = struct {
390390 },
391391
392392 // TODO: A bit of duplication here and in the following state, redo.
393 State.ValueBeginNoClosing => switch (c) {
393 .ValueBeginNoClosing => switch (c) {
394394 '{' => {
395395 if (p.stack_used == max_stack_size) {
396396 return error.TooManyNestedItems;
......@@ -400,8 +400,8 @@ pub const StreamingParser = struct {
400400 p.stack |= object_bit;
401401 p.stack_used += 1;
402402
403 p.state = State.ValueBegin;
404 p.after_string_state = State.ObjectSeparator;
403 p.state = .ValueBegin;
404 p.after_string_state = .ObjectSeparator;
405405
406406 token.* = Token.ObjectBegin;
407407 },
......@@ -414,40 +414,40 @@ pub const StreamingParser = struct {
414414 p.stack |= array_bit;
415415 p.stack_used += 1;
416416
417 p.state = State.ValueBegin;
418 p.after_string_state = State.ValueEnd;
417 p.state = .ValueBegin;
418 p.after_string_state = .ValueEnd;
419419
420420 token.* = Token.ArrayBegin;
421421 },
422422 '-' => {
423423 p.number_is_integer = true;
424 p.state = State.Number;
424 p.state = .Number;
425425 p.count = 0;
426426 },
427427 '0' => {
428428 p.number_is_integer = true;
429 p.state = State.NumberMaybeDotOrExponent;
429 p.state = .NumberMaybeDotOrExponent;
430430 p.count = 0;
431431 },
432432 '1'...'9' => {
433433 p.number_is_integer = true;
434 p.state = State.NumberMaybeDigitOrDotOrExponent;
434 p.state = .NumberMaybeDigitOrDotOrExponent;
435435 p.count = 0;
436436 },
437437 '"' => {
438 p.state = State.String;
438 p.state = .String;
439439 p.count = 0;
440440 },
441441 't' => {
442 p.state = State.TrueLiteral1;
442 p.state = .TrueLiteral1;
443443 p.count = 0;
444444 },
445445 'f' => {
446 p.state = State.FalseLiteral1;
446 p.state = .FalseLiteral1;
447447 p.count = 0;
448448 },
449449 'n' => {
450 p.state = State.NullLiteral1;
450 p.state = .NullLiteral1;
451451 p.count = 0;
452452 },
453453 0x09, 0x0A, 0x0D, 0x20 => {
......@@ -458,17 +458,17 @@ pub const StreamingParser = struct {
458458 },
459459 },
460460
461 State.ValueEnd => switch (c) {
461 .ValueEnd => switch (c) {
462462 ',' => {
463463 p.after_string_state = State.fromInt(p.stack & 1);
464 p.state = State.ValueBeginNoClosing;
464 p.state = .ValueBeginNoClosing;
465465 },
466466 ']' => {
467467 if (p.stack_used == 0) {
468468 return error.UnbalancedBrackets;
469469 }
470470
471 p.state = State.ValueEnd;
471 p.state = .ValueEnd;
472472 p.after_string_state = State.fromInt(p.stack & 1);
473473
474474 p.stack >>= 1;
......@@ -476,7 +476,7 @@ pub const StreamingParser = struct {
476476
477477 if (p.stack_used == 0) {
478478 p.complete = true;
479 p.state = State.TopLevelEnd;
479 p.state = .TopLevelEnd;
480480 }
481481
482482 token.* = Token.ArrayEnd;
......@@ -486,7 +486,7 @@ pub const StreamingParser = struct {
486486 return error.UnbalancedBraces;
487487 }
488488
489 p.state = State.ValueEnd;
489 p.state = .ValueEnd;
490490 p.after_string_state = State.fromInt(p.stack & 1);
491491
492492 p.stack >>= 1;
......@@ -494,7 +494,7 @@ pub const StreamingParser = struct {
494494
495495 if (p.stack_used == 0) {
496496 p.complete = true;
497 p.state = State.TopLevelEnd;
497 p.state = .TopLevelEnd;
498498 }
499499
500500 token.* = Token.ObjectEnd;
......@@ -507,10 +507,10 @@ pub const StreamingParser = struct {
507507 },
508508 },
509509
510 State.ObjectSeparator => switch (c) {
510 .ObjectSeparator => switch (c) {
511511 ':' => {
512 p.state = State.ValueBegin;
513 p.after_string_state = State.ValueEnd;
512 p.state = .ValueBegin;
513 p.after_string_state = .ValueEnd;
514514 },
515515 0x09, 0x0A, 0x0D, 0x20 => {
516516 // whitespace
......@@ -520,14 +520,14 @@ pub const StreamingParser = struct {
520520 },
521521 },
522522
523 State.String => switch (c) {
523 .String => switch (c) {
524524 0x00...0x1F => {
525525 return error.InvalidControlCharacter;
526526 },
527527 '"' => {
528528 p.state = p.after_string_state;
529 if (p.after_value_state == State.TopLevelEnd) {
530 p.state = State.TopLevelEnd;
529 if (p.after_value_state == .TopLevelEnd) {
530 p.state = .TopLevelEnd;
531531 p.complete = true;
532532 }
533533
......@@ -539,41 +539,41 @@ pub const StreamingParser = struct {
539539 };
540540 },
541541 '\\' => {
542 p.state = State.StringEscapeCharacter;
542 p.state = .StringEscapeCharacter;
543543 },
544544 0x20, 0x21, 0x23...0x5B, 0x5D...0x7F => {
545545 // non-control ascii
546546 },
547547 0xC0...0xDF => {
548 p.state = State.StringUtf8Byte1;
548 p.state = .StringUtf8Byte1;
549549 },
550550 0xE0...0xEF => {
551 p.state = State.StringUtf8Byte2;
551 p.state = .StringUtf8Byte2;
552552 },
553553 0xF0...0xFF => {
554 p.state = State.StringUtf8Byte3;
554 p.state = .StringUtf8Byte3;
555555 },
556556 else => {
557557 return error.InvalidUtf8Byte;
558558 },
559559 },
560560
561 State.StringUtf8Byte3 => switch (c >> 6) {
562 0b10 => p.state = State.StringUtf8Byte2,
561 .StringUtf8Byte3 => switch (c >> 6) {
562 0b10 => p.state = .StringUtf8Byte2,
563563 else => return error.InvalidUtf8Byte,
564564 },
565565
566 State.StringUtf8Byte2 => switch (c >> 6) {
567 0b10 => p.state = State.StringUtf8Byte1,
566 .StringUtf8Byte2 => switch (c >> 6) {
567 0b10 => p.state = .StringUtf8Byte1,
568568 else => return error.InvalidUtf8Byte,
569569 },
570570
571 State.StringUtf8Byte1 => switch (c >> 6) {
572 0b10 => p.state = State.String,
571 .StringUtf8Byte1 => switch (c >> 6) {
572 0b10 => p.state = .String,
573573 else => return error.InvalidUtf8Byte,
574574 },
575575
576 State.StringEscapeCharacter => switch (c) {
576 .StringEscapeCharacter => switch (c) {
577577 // NOTE: '/' is allowed as an escaped character but it also is allowed
578578 // as unescaped according to the RFC. There is a reported errata which suggests
579579 // removing the non-escaped variant but it makes more sense to simply disallow
......@@ -584,53 +584,53 @@ pub const StreamingParser = struct {
584584 // is further clarified.
585585 '"', '\\', '/', 'b', 'f', 'n', 'r', 't' => {
586586 p.string_has_escape = true;
587 p.state = State.String;
587 p.state = .String;
588588 },
589589 'u' => {
590590 p.string_has_escape = true;
591 p.state = State.StringEscapeHexUnicode4;
591 p.state = .StringEscapeHexUnicode4;
592592 },
593593 else => {
594594 return error.InvalidEscapeCharacter;
595595 },
596596 },
597597
598 State.StringEscapeHexUnicode4 => switch (c) {
598 .StringEscapeHexUnicode4 => switch (c) {
599599 '0'...'9', 'A'...'F', 'a'...'f' => {
600 p.state = State.StringEscapeHexUnicode3;
600 p.state = .StringEscapeHexUnicode3;
601601 },
602602 else => return error.InvalidUnicodeHexSymbol,
603603 },
604604
605 State.StringEscapeHexUnicode3 => switch (c) {
605 .StringEscapeHexUnicode3 => switch (c) {
606606 '0'...'9', 'A'...'F', 'a'...'f' => {
607 p.state = State.StringEscapeHexUnicode2;
607 p.state = .StringEscapeHexUnicode2;
608608 },
609609 else => return error.InvalidUnicodeHexSymbol,
610610 },
611611
612 State.StringEscapeHexUnicode2 => switch (c) {
612 .StringEscapeHexUnicode2 => switch (c) {
613613 '0'...'9', 'A'...'F', 'a'...'f' => {
614 p.state = State.StringEscapeHexUnicode1;
614 p.state = .StringEscapeHexUnicode1;
615615 },
616616 else => return error.InvalidUnicodeHexSymbol,
617617 },
618618
619 State.StringEscapeHexUnicode1 => switch (c) {
619 .StringEscapeHexUnicode1 => switch (c) {
620620 '0'...'9', 'A'...'F', 'a'...'f' => {
621 p.state = State.String;
621 p.state = .String;
622622 },
623623 else => return error.InvalidUnicodeHexSymbol,
624624 },
625625
626 State.Number => {
627 p.complete = p.after_value_state == State.TopLevelEnd;
626 .Number => {
627 p.complete = p.after_value_state == .TopLevelEnd;
628628 switch (c) {
629629 '0' => {
630 p.state = State.NumberMaybeDotOrExponent;
630 p.state = .NumberMaybeDotOrExponent;
631631 },
632632 '1'...'9' => {
633 p.state = State.NumberMaybeDigitOrDotOrExponent;
633 p.state = .NumberMaybeDigitOrDotOrExponent;
634634 },
635635 else => {
636636 return error.InvalidNumber;
......@@ -638,16 +638,16 @@ pub const StreamingParser = struct {
638638 }
639639 },
640640
641 State.NumberMaybeDotOrExponent => {
642 p.complete = p.after_value_state == State.TopLevelEnd;
641 .NumberMaybeDotOrExponent => {
642 p.complete = p.after_value_state == .TopLevelEnd;
643643 switch (c) {
644644 '.' => {
645645 p.number_is_integer = false;
646 p.state = State.NumberFractionalRequired;
646 p.state = .NumberFractionalRequired;
647647 },
648648 'e', 'E' => {
649649 p.number_is_integer = false;
650 p.state = State.NumberExponent;
650 p.state = .NumberExponent;
651651 },
652652 else => {
653653 p.state = p.after_value_state;
......@@ -662,16 +662,16 @@ pub const StreamingParser = struct {
662662 }
663663 },
664664
665 State.NumberMaybeDigitOrDotOrExponent => {
666 p.complete = p.after_value_state == State.TopLevelEnd;
665 .NumberMaybeDigitOrDotOrExponent => {
666 p.complete = p.after_value_state == .TopLevelEnd;
667667 switch (c) {
668668 '.' => {
669669 p.number_is_integer = false;
670 p.state = State.NumberFractionalRequired;
670 p.state = .NumberFractionalRequired;
671671 },
672672 'e', 'E' => {
673673 p.number_is_integer = false;
674 p.state = State.NumberExponent;
674 p.state = .NumberExponent;
675675 },
676676 '0'...'9' => {
677677 // another digit
......@@ -689,11 +689,11 @@ pub const StreamingParser = struct {
689689 }
690690 },
691691
692 State.NumberFractionalRequired => {
693 p.complete = p.after_value_state == State.TopLevelEnd;
692 .NumberFractionalRequired => {
693 p.complete = p.after_value_state == .TopLevelEnd;
694694 switch (c) {
695695 '0'...'9' => {
696 p.state = State.NumberFractional;
696 p.state = .NumberFractional;
697697 },
698698 else => {
699699 return error.InvalidNumber;
......@@ -701,15 +701,15 @@ pub const StreamingParser = struct {
701701 }
702702 },
703703
704 State.NumberFractional => {
705 p.complete = p.after_value_state == State.TopLevelEnd;
704 .NumberFractional => {
705 p.complete = p.after_value_state == .TopLevelEnd;
706706 switch (c) {
707707 '0'...'9' => {
708708 // another digit
709709 },
710710 'e', 'E' => {
711711 p.number_is_integer = false;
712 p.state = State.NumberExponent;
712 p.state = .NumberExponent;
713713 },
714714 else => {
715715 p.state = p.after_value_state;
......@@ -724,12 +724,12 @@ pub const StreamingParser = struct {
724724 }
725725 },
726726
727 State.NumberMaybeExponent => {
728 p.complete = p.after_value_state == State.TopLevelEnd;
727 .NumberMaybeExponent => {
728 p.complete = p.after_value_state == .TopLevelEnd;
729729 switch (c) {
730730 'e', 'E' => {
731731 p.number_is_integer = false;
732 p.state = State.NumberExponent;
732 p.state = .NumberExponent;
733733 },
734734 else => {
735735 p.state = p.after_value_state;
......@@ -744,32 +744,32 @@ pub const StreamingParser = struct {
744744 }
745745 },
746746
747 State.NumberExponent => switch (c) {
747 .NumberExponent => switch (c) {
748748 '-', '+' => {
749749 p.complete = false;
750 p.state = State.NumberExponentDigitsRequired;
750 p.state = .NumberExponentDigitsRequired;
751751 },
752752 '0'...'9' => {
753 p.complete = p.after_value_state == State.TopLevelEnd;
754 p.state = State.NumberExponentDigits;
753 p.complete = p.after_value_state == .TopLevelEnd;
754 p.state = .NumberExponentDigits;
755755 },
756756 else => {
757757 return error.InvalidNumber;
758758 },
759759 },
760760
761 State.NumberExponentDigitsRequired => switch (c) {
761 .NumberExponentDigitsRequired => switch (c) {
762762 '0'...'9' => {
763 p.complete = p.after_value_state == State.TopLevelEnd;
764 p.state = State.NumberExponentDigits;
763 p.complete = p.after_value_state == .TopLevelEnd;
764 p.state = .NumberExponentDigits;
765765 },
766766 else => {
767767 return error.InvalidNumber;
768768 },
769769 },
770770
771 State.NumberExponentDigits => {
772 p.complete = p.after_value_state == State.TopLevelEnd;
771 .NumberExponentDigits => {
772 p.complete = p.after_value_state == .TopLevelEnd;
773773 switch (c) {
774774 '0'...'9' => {
775775 // another digit
......@@ -787,20 +787,20 @@ pub const StreamingParser = struct {
787787 }
788788 },
789789
790 State.TrueLiteral1 => switch (c) {
791 'r' => p.state = State.TrueLiteral2,
790 .TrueLiteral1 => switch (c) {
791 'r' => p.state = .TrueLiteral2,
792792 else => return error.InvalidLiteral,
793793 },
794794
795 State.TrueLiteral2 => switch (c) {
796 'u' => p.state = State.TrueLiteral3,
795 .TrueLiteral2 => switch (c) {
796 'u' => p.state = .TrueLiteral3,
797797 else => return error.InvalidLiteral,
798798 },
799799
800 State.TrueLiteral3 => switch (c) {
800 .TrueLiteral3 => switch (c) {
801801 'e' => {
802802 p.state = p.after_value_state;
803 p.complete = p.state == State.TopLevelEnd;
803 p.complete = p.state == .TopLevelEnd;
804804 token.* = Token.True;
805805 },
806806 else => {
......@@ -808,25 +808,25 @@ pub const StreamingParser = struct {
808808 },
809809 },
810810
811 State.FalseLiteral1 => switch (c) {
812 'a' => p.state = State.FalseLiteral2,
811 .FalseLiteral1 => switch (c) {
812 'a' => p.state = .FalseLiteral2,
813813 else => return error.InvalidLiteral,
814814 },
815815
816 State.FalseLiteral2 => switch (c) {
817 'l' => p.state = State.FalseLiteral3,
816 .FalseLiteral2 => switch (c) {
817 'l' => p.state = .FalseLiteral3,
818818 else => return error.InvalidLiteral,
819819 },
820820
821 State.FalseLiteral3 => switch (c) {
822 's' => p.state = State.FalseLiteral4,
821 .FalseLiteral3 => switch (c) {
822 's' => p.state = .FalseLiteral4,
823823 else => return error.InvalidLiteral,
824824 },
825825
826 State.FalseLiteral4 => switch (c) {
826 .FalseLiteral4 => switch (c) {
827827 'e' => {
828828 p.state = p.after_value_state;
829 p.complete = p.state == State.TopLevelEnd;
829 p.complete = p.state == .TopLevelEnd;
830830 token.* = Token.False;
831831 },
832832 else => {
......@@ -834,20 +834,20 @@ pub const StreamingParser = struct {
834834 },
835835 },
836836
837 State.NullLiteral1 => switch (c) {
838 'u' => p.state = State.NullLiteral2,
837 .NullLiteral1 => switch (c) {
838 'u' => p.state = .NullLiteral2,
839839 else => return error.InvalidLiteral,
840840 },
841841
842 State.NullLiteral2 => switch (c) {
843 'l' => p.state = State.NullLiteral3,
842 .NullLiteral2 => switch (c) {
843 'l' => p.state = .NullLiteral3,
844844 else => return error.InvalidLiteral,
845845 },
846846
847 State.NullLiteral3 => switch (c) {
847 .NullLiteral3 => switch (c) {
848848 'l' => {
849849 p.state = p.after_value_state;
850 p.complete = p.state == State.TopLevelEnd;
850 p.complete = p.state == .TopLevelEnd;
851851 token.* = Token.Null;
852852 },
853853 else => {
......@@ -1075,7 +1075,7 @@ pub const Parser = struct {
10751075 pub fn init(allocator: *Allocator, copy_strings: bool) Parser {
10761076 return Parser{
10771077 .allocator = allocator,
1078 .state = State.Simple,
1078 .state = .Simple,
10791079 .copy_strings = copy_strings,
10801080 .stack = Array.init(allocator),
10811081 };
......@@ -1086,7 +1086,7 @@ pub const Parser = struct {
10861086 }
10871087
10881088 pub fn reset(p: *Parser) void {
1089 p.state = State.Simple;
1089 p.state = .Simple;
10901090 p.stack.shrink(0);
10911091 }
10921092
......@@ -1112,7 +1112,7 @@ pub const Parser = struct {
11121112 // can be cleaned up on error correctly during a `parse` on call.
11131113 fn transition(p: *Parser, allocator: *Allocator, input: []const u8, i: usize, token: Token) !void {
11141114 switch (p.state) {
1115 State.ObjectKey => switch (token) {
1115 .ObjectKey => switch (token) {
11161116 .ObjectEnd => {
11171117 if (p.stack.len == 1) {
11181118 return;
......@@ -1123,7 +1123,7 @@ pub const Parser = struct {
11231123 },
11241124 .String => |s| {
11251125 try p.stack.append(try p.parseString(allocator, s, input, i));
1126 p.state = State.ObjectValue;
1126 p.state = .ObjectValue;
11271127 },
11281128 else => {
11291129 // The streaming parser would return an error eventually.
......@@ -1132,50 +1132,50 @@ pub const Parser = struct {
11321132 return error.InvalidLiteral;
11331133 },
11341134 },
1135 State.ObjectValue => {
1135 .ObjectValue => {
11361136 var object = &p.stack.items[p.stack.len - 2].Object;
11371137 var key = p.stack.items[p.stack.len - 1].String;
11381138
11391139 switch (token) {
11401140 .ObjectBegin => {
11411141 try p.stack.append(Value{ .Object = ObjectMap.init(allocator) });
1142 p.state = State.ObjectKey;
1142 p.state = .ObjectKey;
11431143 },
11441144 .ArrayBegin => {
11451145 try p.stack.append(Value{ .Array = Array.init(allocator) });
1146 p.state = State.ArrayValue;
1146 p.state = .ArrayValue;
11471147 },
11481148 .String => |s| {
11491149 _ = try object.put(key, try p.parseString(allocator, s, input, i));
11501150 _ = p.stack.pop();
1151 p.state = State.ObjectKey;
1151 p.state = .ObjectKey;
11521152 },
11531153 .Number => |n| {
11541154 _ = try object.put(key, try p.parseNumber(n, input, i));
11551155 _ = p.stack.pop();
1156 p.state = State.ObjectKey;
1156 p.state = .ObjectKey;
11571157 },
11581158 .True => {
11591159 _ = try object.put(key, Value{ .Bool = true });
11601160 _ = p.stack.pop();
1161 p.state = State.ObjectKey;
1161 p.state = .ObjectKey;
11621162 },
11631163 .False => {
11641164 _ = try object.put(key, Value{ .Bool = false });
11651165 _ = p.stack.pop();
1166 p.state = State.ObjectKey;
1166 p.state = .ObjectKey;
11671167 },
11681168 .Null => {
11691169 _ = try object.put(key, Value.Null);
11701170 _ = p.stack.pop();
1171 p.state = State.ObjectKey;
1171 p.state = .ObjectKey;
11721172 },
11731173 .ObjectEnd, .ArrayEnd => {
11741174 unreachable;
11751175 },
11761176 }
11771177 },
1178 State.ArrayValue => {
1178 .ArrayValue => {
11791179 var array = &p.stack.items[p.stack.len - 1].Array;
11801180
11811181 switch (token) {
......@@ -1189,11 +1189,11 @@ pub const Parser = struct {
11891189 },
11901190 .ObjectBegin => {
11911191 try p.stack.append(Value{ .Object = ObjectMap.init(allocator) });
1192 p.state = State.ObjectKey;
1192 p.state = .ObjectKey;
11931193 },
11941194 .ArrayBegin => {
11951195 try p.stack.append(Value{ .Array = Array.init(allocator) });
1196 p.state = State.ArrayValue;
1196 p.state = .ArrayValue;
11971197 },
11981198 .String => |s| {
11991199 try array.append(try p.parseString(allocator, s, input, i));
......@@ -1215,14 +1215,14 @@ pub const Parser = struct {
12151215 },
12161216 }
12171217 },
1218 State.Simple => switch (token) {
1218 .Simple => switch (token) {
12191219 .ObjectBegin => {
12201220 try p.stack.append(Value{ .Object = ObjectMap.init(allocator) });
1221 p.state = State.ObjectKey;
1221 p.state = .ObjectKey;
12221222 },
12231223 .ArrayBegin => {
12241224 try p.stack.append(Value{ .Array = Array.init(allocator) });
1225 p.state = State.ArrayValue;
1225 p.state = .ArrayValue;
12261226 },
12271227 .String => |s| {
12281228 try p.stack.append(try p.parseString(allocator, s, input, i));
......@@ -1254,12 +1254,12 @@ pub const Parser = struct {
12541254
12551255 var object = &p.stack.items[p.stack.len - 1].Object;
12561256 _ = try object.put(key, value.*);
1257 p.state = State.ObjectKey;
1257 p.state = .ObjectKey;
12581258 },
12591259 // Array Parent -> [ ..., <array>, value ]
12601260 Value.Array => |*array| {
12611261 try array.append(value.*);
1262 p.state = State.ArrayValue;
1262 p.state = .ArrayValue;
12631263 },
12641264 else => {
12651265 unreachable;