diff --git a/preserves.nimble b/preserves.nimble index b4642ef..662b1b2 100644 --- a/preserves.nimble +++ b/preserves.nimble @@ -1,6 +1,6 @@ # Package -version = "20231224" +version = "20231225" author = "Emery Hemingway" description = "data model and serialization format" license = "Unlicense" diff --git a/src/preserves/pegs.nim b/src/preserves/pegs.nim index 7e62470..69c2934 100644 --- a/src/preserves/pegs.nim +++ b/src/preserves/pegs.nim @@ -15,15 +15,15 @@ grammar "Preserves": Document <- Value * ws * !1 + Atom <- Boolean | Float | Double | FloatRaw | DoubleRaw | SignedInteger | String | ByteString | Symbol + + Collection <- Sequence | Dictionary | Set + Value <- (ws * (Record | Collection | Atom | Embedded | Compact)) | (ws * Annotation) | (ws * '#' * @'\n' * Value) - Collection <- Sequence | Dictionary | Set - - Atom <- Boolean | Float | Double | FloatRaw | DoubleRaw | SignedInteger | String | ByteString | Symbol - Record <- '<' * +Value * ws * '>' Sequence <- '[' * *(commas * Value) * commas * ']' @@ -45,19 +45,24 @@ grammar "Preserves": SignedInteger <- int * &delimiter - char <- unescaped | '|' | (escape * (escaped | '"' | ('u' * Xdigit[4]))) + unescaped <- utf8.any - { '\x00'..'\x19', '"', '\\', '|' } + unicodeEscaped <- 'u' * Xdigit[4] + escaped <- {'\\', '/', 'b', 'f', 'n', 'r', 't'} + escape <- '\\' + + char <- unescaped | '|' | (escape * (escaped | '"' | unicodeEscaped)) String <- '"' * >(*char) * '"' + binunescaped <- {' '..'!', '#'..'[', ']'..'~'} + binchar <- binunescaped | (escape * (escaped | '"' | ('x' * Xdigit[2]))) + ByteString <- charByteString | hexByteString | b64ByteString charByteString <- "#\"" * >(*binchar) * '"' hexByteString <- "#x\"" * >(*(ws * Xdigit[2])) * ws * '"' base64char <- {'A'..'Z', 'a'..'z', '0'..'9', '+', '/', '-', '_', '='} b64ByteString <- "#[" * >(*(ws * base64char)) * ws * ']' - binchar <- binunescaped | (escape * (escaped | '"' | ('x' * Xdigit[2]))) - binunescaped <- {' '..'!', '#'..'[', ']'..'~'} - - symchar <- (utf8.any - {'\\', '|'}) | (escape * (escaped | ('u' * Xdigit[4]))) | "\\|" + symchar <- (utf8.any - {'\\', '|'}) | (escape * (escaped | unicodeEscaped)) | "\\|" QuotedSymbol <- '|' * >(*symchar) * '|' sympunct <- {'~', '!', '$', '%', '^', '&', '*', '?', '_', '=', '+', '-', '/', '.'} symuchar <- utf8.any - { 0..127 } @@ -70,10 +75,5 @@ grammar "Preserves": Compact <- "#=" * ws * ByteString - unescaped <- utf8.any - { '\x00'..'\x19', '"', '\\', '|' } - unicodeEscaped <- 'u' * Xdigit[4] - escaped <- {'\\', '/', 'b', 'f', 'n', 'r', 't'} - escape <- '\\' - FloatRaw <- "#xf\"" * >((ws * Xdigit[2])[4]) * ws * '"' DoubleRaw <- "#xd\"" * >((ws * Xdigit[2])[8]) * ws * '"'