forked from syndicate-lang/preserves
The Racket preserves package needs a local copy of schema.prs for the package-builder to work. Use a git hook to keep it in sync with the master copy
This commit is contained in:
parent
7ab12108e4
commit
90ce0a544d
2
Makefile
2
Makefile
|
@ -1,3 +1,5 @@
|
|||
__ignored__ := $(shell ./setup.sh)
|
||||
|
||||
PDFS=preserves.pdf preserves-schema.pdf
|
||||
|
||||
all: $(PDFS)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
exec 1>&2
|
||||
|
||||
# Ensure that various copies of schema.prs are in fact identical.
|
||||
cmp schema/schema.prs implementations/racket/preserves/preserves-schema/schema.prs
|
|
@ -1,4 +1,4 @@
|
|||
#lang preserves-schema
|
||||
|
||||
version 1 .
|
||||
include "../../../../schema/schema.prs" .
|
||||
include "./schema.prs" .
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
@<EmacsMode "-*- preserves -*-">
|
||||
|
||||
; TODO: some kind of constants
|
||||
; TODO: rename "version" to "schema-version" ?
|
||||
|
||||
version 1 .
|
||||
|
||||
Bundle = <bundle @modules Modules>.
|
||||
Modules = { ModulePath: Schema ...:... }.
|
||||
|
||||
Schema = <schema {
|
||||
version: Version
|
||||
embeddedType: EmbeddedTypeName
|
||||
definitions: Definitions
|
||||
}>.
|
||||
|
||||
; version 1 .
|
||||
Version = 1 .
|
||||
|
||||
EmbeddedTypeName = Ref / #f.
|
||||
|
||||
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, float, double, int, string, bytes, symbol
|
||||
/ <atom @atomKind AtomKind>
|
||||
|
||||
; matches an embedded value in the input: embedded
|
||||
/ <embedded>
|
||||
|
||||
; =symbol, <<lit> any>, or plain non-symbol atom
|
||||
/ <lit @value any>
|
||||
|
||||
; [p ...] ----> <seqof <ref p>>; see also tuple* 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
|
||||
.
|
||||
|
||||
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>>
|
||||
/ <rec @label NamedPattern @fields NamedPattern>
|
||||
|
||||
; [a b c] ----> <tuple [<ref a> <ref b> <ref c>]>
|
||||
/ <tuple @patterns [NamedPattern ...]>
|
||||
|
||||
; [a b c ...] ----> <tuple* [<ref a> <ref b>] <seqof <ref c>>>
|
||||
; TODO: [@fixed0 NamedPattern @fixedN NamedPattern ...]
|
||||
/ <tuple* @fixed [NamedPattern ...] @variable NamedSimplePattern>
|
||||
|
||||
; {a: b, c: d} ----> <dict {a: <ref b>, c: <ref d>}>
|
||||
/ <dict @entries DictionaryEntries>
|
||||
.
|
||||
|
||||
DictionaryEntries = { any: NamedSimplePattern ...:... }.
|
||||
|
||||
AtomKind = =Boolean / =Float / =Double / =SignedInteger / =String / =ByteString / =Symbol .
|
||||
|
||||
NamedAlternative = [@variantLabel string @pattern Pattern].
|
||||
|
||||
NamedSimplePattern = @named NamedSimplePattern_ / @anonymous SimplePattern .
|
||||
NamedPattern = @named NamedSimplePattern_ / @anonymous Pattern .
|
||||
|
||||
NamedSimplePattern_ = <named @name symbol @pattern SimplePattern>.
|
||||
|
||||
Ref = <ref @module ModulePath @name symbol>.
|
||||
ModulePath = [symbol ...].
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Set up a git checkout of this repository for local dev use.
|
||||
|
||||
exec 2>/dev/tty 1>&2
|
||||
|
||||
set -e
|
||||
|
||||
[ -d .git ] || exit 0
|
||||
|
||||
for fullhook in ./git-hooks/*
|
||||
do
|
||||
hook=$(basename "$fullhook")
|
||||
[ -L .git/hooks/$hook ] || (
|
||||
echo "Installing $hook hook"
|
||||
ln -s ../../git-hooks/$hook .git/hooks/$hook
|
||||
)
|
||||
done
|
Loading…
Reference in New Issue