preserves/schema/schema.prs

65 lines
1.6 KiB
Plaintext

@<EmacsMode "-*- preserves -*-">
version 1 .
Schema = <schema @details {
version: Version
pointer: PointerName
definitions: { symbol: Pattern ...:... }
}>.
; version 1 .
Version = 1 .
PointerName = Ref / #f.
Pattern = <<or> [
; special builtins or <<atom> symbol>
<atom @atomKind <<or> [=Boolean =Float =Double =SignedInteger =String =ByteString =Symbol]>>
; matches a pointer in the input
<pointer>
; =symbol, <<lit> any>, or plain non-symbol atom
<lit @value any>
; symbol, symbol.symbol, symbol.symbol.symbol, ...
Ref
; Pattern / Pattern / ...
; <<or> [Pattern Pattern ...]>
; and the empty pattern is <<or> []>
<or @patterns [Pattern ...]>
; Pattern & Pattern & ...
; <<and> [Pattern Pattern ...]>
; and the universal pattern, "any", is <<and> []>
<and @patterns [Pattern ...]>
; <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>>
<rec @label Pattern @fields Pattern>
; [a b c] ----> <tuple [<ref a> <ref b> <ref c>]>
<tuple @patterns [NamedPattern ...]>
; [a b c ...] ----> <tuple* [<ref a> <ref b>] <ref c>]>
<tuple* @fixed [NamedPattern ...] @variable NamedPattern>
; #{p} ----> <setof <ref p>>
<setof @pattern Pattern>
; {k: v, ...:...} ----> <dictof <ref k> <ref v>>
<dictof @key Pattern @value Pattern>
; {a: b, c: d} ----> <dict {a: <ref b>, c: <ref d>}>
<dict @entries { any: Pattern ...:... }>
]>.
NamedPattern = <named @name symbol @pattern Pattern> / Pattern .
Ref = <ref @module ModuleRef @name symbol>.
ModuleRef = =thisModule / ModulePath .
ModulePath = [symbol ...].