preserves/schema/schema.prs

89 lines
2.2 KiB
Plaintext
Raw Normal View History

2021-03-09 14:59:40 +00:00
@<EmacsMode "-*- preserves -*-">
; TODO: some kind of constants
; TODO: rename "version" to "schema-version" ?
2021-03-09 14:59:40 +00:00
version 1 .
2021-04-01 18:31:08 +00:00
Bundle = <bundle @modules Modules>.
Modules = { ModulePath: Schema ...:... }.
Schema = <schema {
2021-03-09 14:59:40 +00:00
version: Version
embeddedType: EmbeddedTypeName
2021-03-17 18:17:19 +00:00
definitions: Definitions
2021-03-09 14:59:40 +00:00
}>.
; version 1 .
Version = 1 .
EmbeddedTypeName = Ref / #f.
2021-03-11 16:59:40 +00:00
2021-03-17 18:17:19 +00:00
Definitions = { symbol: Definition ...:... }.
Definition =
; Pattern / Pattern / ...
/ <or [@pattern NamedAlternative @patterns NamedAlternative ...]>
; Pattern & Pattern & ...
/ <and [@pattern NamedPattern @patterns NamedPattern ...]>
; Pattern
/ Pattern
.
Pattern = SimplePattern / CompoundPattern .
SimplePattern =
; any
/ =any
; special builtins: bool, float, double, int, string, bytes, symbol
/ <atom @atomKind AtomKind>
2021-03-09 14:59:40 +00:00
; matches an embedded value in the input: embedded
/ <embedded>
2021-03-09 15:45:57 +00:00
2021-03-09 14:59:40 +00:00
; =symbol, <<lit> any>, or plain non-symbol atom
/ <lit @value any>
2021-03-09 14:59:40 +00:00
2021-03-11 09:56:49 +00:00
; symbol, symbol.symbol, symbol.symbol.symbol, ...
/ Ref
.
2021-03-09 14:59:40 +00:00
CompoundPattern =
2021-03-09 14:59:40 +00:00
; <label a b c> ----> <rec <lit label> <tuple [<ref a> <ref b> <ref c>]>>
; except for record labels
; <<rec> x y> ---> <rec <ref x> <ref y>>
2021-03-17 18:17:19 +00:00
/ <rec @label NamedPattern @fields NamedPattern>
2021-03-09 14:59:40 +00:00
; [a b c] ----> <tuple [<ref a> <ref b> <ref c>]>
/ <tuple [@patterns NamedPattern ...]>
2021-03-09 14:59:40 +00:00
; [a b c ...] ----> <tuple* [<ref a> <ref b>] <ref c>]>
2021-03-17 19:01:26 +00:00
/ <tuple* [@fixed NamedPattern ...] @variable NamedSimplePattern>
2021-03-09 14:59:40 +00:00
; #{p} ----> <setof <ref p>>
/ <setof @pattern SimplePattern>
2021-03-09 14:59:40 +00:00
; {k: v, ...:...} ----> <dictof <ref k> <ref v>>
/ <dictof @key SimplePattern @value SimplePattern>
2021-03-09 14:59:40 +00:00
; {a: b, c: d} ----> <dict {a: <ref b>, c: <ref d>}>
/ <dict @entries DictionaryEntries>
.
2021-03-17 19:01:26 +00:00
DictionaryEntries = { any: NamedSimplePattern ...:... }.
AtomKind = =Boolean / =Float / =Double / =SignedInteger / =String / =ByteString / =Symbol .
2021-03-09 14:59:40 +00:00
NamedAlternative = [@variantLabel string @pattern Pattern].
2021-03-17 19:23:55 +00:00
NamedSimplePattern = @named NamedSimplePattern_ / @anonymous SimplePattern .
NamedPattern = @named NamedSimplePattern_ / @anonymous Pattern .
2021-03-17 19:01:26 +00:00
NamedSimplePattern_ = <named @name symbol @pattern SimplePattern>.
2021-03-11 09:56:49 +00:00
2021-03-14 21:59:53 +00:00
Ref = <ref @module ModulePath @name symbol>.
2021-03-11 09:56:49 +00:00
ModulePath = [symbol ...].