preserves/schema/schema.prs

93 lines
2.4 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 .
2021-03-09 14:59:40 +00:00
Version = 1 .
EmbeddedTypeName = #f / Ref .
2021-03-11 16:59:40 +00:00
2021-03-17 18:17:19 +00:00
Definitions = { symbol: Definition ...:... }.
Definition =
# Pattern / Pattern / ...
/ <or [@pattern0 NamedAlternative @pattern1 NamedAlternative @patternN NamedAlternative ...]>
# Pattern & Pattern & ...
/ <and [@pattern0 NamedPattern @pattern1 NamedPattern @patternN NamedPattern ...]>
# Pattern
/ Pattern
.
Pattern = SimplePattern / CompoundPattern .
SimplePattern =
# any
/ =any
# special builtins: bool, double, int, string, bytes, symbol
/ <atom @atomKind AtomKind>
2021-03-09 14:59:40 +00:00
# matches an embedded value in the input: #:p
/ <embedded @interface SimplePattern>
2021-03-09 15:45:57 +00:00
# =symbol, <<lit> any>, or plain non-symbol atom
/ <lit @value any>
2021-03-09 14:59:40 +00:00
# [p ...] ----> <seqof <ref p>>; see also tuplePrefix below.
/ <seqof @pattern SimplePattern>
# #{p} ----> <setof <ref p>>
/ <setof @pattern SimplePattern>
# {k: v, ...:...} ----> <dictof <ref k> <ref v>>
/ <dictof @key SimplePattern @value SimplePattern>
# symbol, symbol.symbol, symbol.symbol.symbol, ...
/ Ref
.
2021-03-09 14:59:40 +00:00
CompoundPattern =
# <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 ...] ----> <tuplePrefix [<ref a> <ref b>] <seqof <ref c>>>
# TODO: [@fixed0 NamedPattern @fixedN NamedPattern ...]
/ <tuplePrefix @fixed [NamedPattern ...] @variable NamedSimplePattern>
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 / =Double / =SignedInteger / =String / =ByteString / =Symbol .
2021-03-09 14:59:40 +00:00
NamedAlternative = [@variantLabel string @pattern Pattern].
2021-06-25 08:25:26 +00:00
NamedSimplePattern = @named Binding / @anonymous SimplePattern .
NamedPattern = @named Binding / @anonymous Pattern .
2021-03-17 19:01:26 +00:00
2021-06-25 08:25:26 +00:00
Binding = <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 ...].