MCPcopy Create free account
hub / github.com/DavidColson/Polybox / ParseTextValue

Function ParseTextValue

source/serialization.cpp:615–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613// ***********************************************************************
614
615void ParseTextValue(lua_State* L, Scan::ScanningState& scan) {
616 while (!Scan::IsAtEnd(scan)) {
617 Scan::AdvanceOverWhitespace(scan);
618 char c = Scan::Advance(scan);
619
620 if (Scan::IsAlpha(c)) {
621 char* pStart = scan.pCurrent - 1;
622 while (Scan::IsAlphaNumeric(Scan::Peek(scan)))
623 Scan::Advance(scan);
624
625 String identifier = CopyCStringRange(pStart, scan.pCurrent, g_pArenaFrame);
626
627 if (identifier == "true")
628 lua_pushboolean(L, 1);
629 else if (identifier == "false")
630 lua_pushboolean(L, 0);
631 else if (identifier == "userdata") {
632 ParseUserData(L, scan);
633 }
634 else {
635 luaL_error(L, "Unexpected identifier in data %s", identifier.pData);
636 }
637 return;
638 }
639
640 // number
641 if (Scan::IsDigit(c) || c == '-' || c == '.') {
642 f64 num = ParseNumber(scan);
643 lua_pushnumber(L, num);
644 return;
645 }
646
647 //string
648 if (c == '\'' || c == '"') {
649 String string = ParseString(g_pArenaFrame, scan, '\"');
650 lua_pushstring(L, string.pData);
651 return;
652 }
653
654 // table
655 if (c == '{') {
656 ParseTextTable(L, scan);
657 return;
658 }
659
660
661 luaL_error(L, "Unexpected character in data to serialize. At location %i", i64(scan.pCurrent - scan.pTextStart));
662 }
663}
664
665// ***********************************************************************
666

Callers 2

ParseTextTableFunction · 0.85
DeserializeFunction · 0.85

Calls 2

ParseUserDataFunction · 0.85
ParseTextTableFunction · 0.85

Tested by

no test coverage detected