preserves/schema/schema.prs

77 lines
2.0 KiB
Plaintext
Raw Normal View History

2021-03-09 14:59:40 +00:00
@<EmacsMode "-*- preserves -*-">
version 1 .
Schema = <schema {
2021-03-09 14:59:40 +00:00
version: Version
2021-03-11 16:59:40 +00:00
pointer: PointerName
2021-03-17 18:17:19 +00:00
definitions: Definitions
2021-03-09 14:59:40 +00:00
}>.
; version 1 .
Version = 1 .
2021-03-11 16:59:40 +00:00
PointerName = Ref / #f.
2021-03-17 18:17:19 +00:00
Definitions = { symbol: Definition ...:... }.
; Pattern / Pattern / ...
; and the empty pattern is <or []>
Definition = <or [@patterns NamedAlternative ...]> / Alternative .
NamedAlternative = [@variantLabel string @alternative Alternative].
; Pattern & Pattern & ...
; and the universal pattern, "any", is <and []>
2021-03-17 15:25:29 +00:00
Alternative = <and [@patterns NamedPattern ...]> / Pattern .
Pattern = SimplePattern / CompoundPattern .
SimplePattern =
; special builtins
/ <atom @atomKind AtomKind>
2021-03-09 14:59:40 +00:00
2021-03-09 15:45:57 +00:00
; matches a pointer in the input
/ <pointer>
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
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 ...].