Parse past annotations
This commit is contained in:
parent
4e795cb92a
commit
2d2df1f918
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "20221030"
|
||||
version = "20221102"
|
||||
author = "Emery Hemingway"
|
||||
description = "data model and serialization format"
|
||||
license = "Unlicense"
|
||||
|
|
|
@ -568,6 +568,11 @@ proc decodePreserves*(s: Stream; E = void): Preserve[E] =
|
|||
result = Preserve[E](kind: pkDouble)
|
||||
var be = s.readFloat64()
|
||||
swapEndian64(result.double.addr, be.addr)
|
||||
of 0x85:
|
||||
discard decodePreserves(s, E)
|
||||
while s.peekUint8() == 0x85:
|
||||
discard s.readUint8()
|
||||
discard decodePreserves(s, E)
|
||||
of 0x86:
|
||||
result = decodePreserves(s, E)
|
||||
result.embedded = true
|
||||
|
|
|
@ -13,7 +13,7 @@ grammar "Preserves":
|
|||
|
||||
Value <-
|
||||
(ws * (Record | Collection | Atom | Embedded | Compact)) |
|
||||
(ws * '@' * Value * Value) |
|
||||
(ws * Annotation) |
|
||||
(ws * ';' * @'\n' * Value)
|
||||
|
||||
Collection <- Sequence | Dictionary | Set
|
||||
|
@ -64,6 +64,8 @@ grammar "Preserves":
|
|||
|
||||
Embedded <- "#!" * Value
|
||||
|
||||
Annotation <- '@' * Value * Value
|
||||
|
||||
Compact <- "#=" * ws * ByteString
|
||||
|
||||
unescaped <- utf8.any - { '\x00'..'\x19', '"', '\\', '|' }
|
||||
|
|
|
@ -166,6 +166,11 @@ proc parsePreserves*(text: string): Preserve[void] {.gcsafe.} =
|
|||
v.embedded = true
|
||||
pushStack v
|
||||
|
||||
Preserves.Annotation <- Preserves.Annotation:
|
||||
var val = stack.pop.value
|
||||
discard stack.pop.value
|
||||
pushStack val
|
||||
|
||||
Preserves.Compact <- Preserves.Compact:
|
||||
pushStack decodePreserves(stack.pop.value.bytes, void)
|
||||
|
||||
|
|
Loading…
Reference in New Issue