Symbol escaping

This commit is contained in:
Emery Hemingway 2022-11-06 11:04:16 -06:00
parent 9f8321a748
commit 99a1cd4d15
4 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,6 @@
# Package # Package
version = "20221102" version = "20221106"
author = "Emery Hemingway" author = "Emery Hemingway"
description = "data model and serialization format" description = "data model and serialization format"
license = "Unlicense" license = "Unlicense"

View File

@ -52,7 +52,7 @@ grammar "Preserves":
binunescaped <- {' '..'!', '#'..'[', ']'..'~'} binunescaped <- {' '..'!', '#'..'[', ']'..'~'}
base64char <- {'A'..'Z', 'a'..'z', '0'..'9', '+', '/', '-', '_', '='} base64char <- {'A'..'Z', 'a'..'z', '0'..'9', '+', '/', '-', '_', '='}
Symbol <- (symstart * *symcont) | ('|' * *symchar * '|') Symbol <- >(symstart * *symcont) | ('|' * >(*symchar) * '|')
symstart <- Alpha | sympunct | symustart symstart <- Alpha | sympunct | symustart
symcont <- Alpha | sympunct | symustart | symucont | Digit | '-' symcont <- Alpha | sympunct | symustart | symucont | Digit | '-'

View File

@ -159,7 +159,7 @@ proc parsePreserves*(text: string): Preserve[void] {.gcsafe.} =
pushStack Value(kind: pkByteString, bytes: cast[seq[byte]](base64.decode(joinWhitespace($1)))) pushStack Value(kind: pkByteString, bytes: cast[seq[byte]](base64.decode(joinWhitespace($1))))
Preserves.Symbol <- Preserves.Symbol: Preserves.Symbol <- Preserves.Symbol:
pushStack Value(kind: pkSymbol, symbol: Symbol $0) pushStack Value(kind: pkSymbol, symbol: Symbol $1)
Preserves.Embedded <- Preserves.Embedded: Preserves.Embedded <- Preserves.Embedded:
var v = stack.pop.value var v = stack.pop.value

View File

@ -272,7 +272,8 @@ const parser = peg("Schema", p: ParseState):
Preserves.String | Preserves.String |
Preserves.ByteString Preserves.ByteString
Value <- Preserves.Value Value <- Preserves.Value:
discard
editorCruft <- '@' * @'\n' editorCruft <- '@' * @'\n'