]> Untitled Git - axy/ft/mini-serde.git/commitdiff
Fixed tags being borked for anything except one char master
authorAxy <gilliardmarthey.axel@gmail.com>
Tue, 10 Feb 2026 03:22:14 +0000 (04:22 +0100)
committerAxy <gilliardmarthey.axel@gmail.com>
Tue, 10 Feb 2026 03:22:14 +0000 (04:22 +0100)
miniserde/serde_data.py

index 6d2da19573bfe9b9bb4b440e2be2e6231801ae35..4b8c31fb93c18bf3d8cfba25579f1a8ccc1edc9a 100644 (file)
@@ -1,9 +1,11 @@
 from collections.abc import Callable
 from typing import cast
 from collections.abc import Callable
 from typing import cast
+from sys import stdin
 
 
 class NullType:
 
 
 class NullType:
-    pass
+    def __repr__(self) -> str:
+        return "null"
 
 
 Null: NullType = NullType()
 
 
 Null: NullType = NullType()
@@ -60,8 +62,8 @@ def cut[T](p: Parser[T]) -> Parser[T]:
 
 
 def tag(tag: str) -> Parser[str]:
 
 
 def tag(tag: str) -> Parser[str]:
-    return parser_flatten(
-        parser_map(lambda s: s if s.startswith(tag) else None, char)
+    return lambda s: (
+        (s[: len(tag)], s[len(tag) :]) if s.startswith(tag) else None
     )
 
 
     )
 
 
@@ -331,6 +333,4 @@ def json_object(s: str) -> ParseResult[dict[str, JsonValue]]:
     )(s)
 
 
     )(s)
 
 
-print(json_value("-12331.111e231"))
-print(json_value('"hello world\\\\ \\" "'))
-print(json_value('[123,  -123e3, {"hello": "axy", "num": 421}]'))
+print(json_value(stdin.read()))