diff --git a/OLD-syndicate/pattern-expander.rkt b/syndicate/pattern-expander.rkt similarity index 100% rename from OLD-syndicate/pattern-expander.rkt rename to syndicate/pattern-expander.rkt diff --git a/OLD-syndicate/pattern.rkt b/syndicate/pattern.rkt similarity index 100% rename from OLD-syndicate/pattern.rkt rename to syndicate/pattern.rkt diff --git a/syndicate/private/install.rkt b/syndicate/private/install.rkt index e169368..a73d28c 100644 --- a/syndicate/private/install.rkt +++ b/syndicate/private/install.rkt @@ -6,12 +6,15 @@ (require preserves-schema/bin/preserves-schema-rkt) (require (only-in racket/file delete-directory/files)) +(require (only-in "../schema-compiler.rkt" schema-compiler-plugin)) + (define (pre-installer _collects-path syndicate-path) (define output-directory (build-path syndicate-path "schemas/gen")) (delete-directory/files output-directory #:must-exist? #f) (batch-compile #:inputs (list (build-path syndicate-path "schemas/**.prs")) #:additional-modules (hash '(Actor) 'syndicate/actor) - #:output-directory output-directory)) + #:output-directory output-directory + #:plugins (list schema-compiler-plugin))) (define-runtime-path syndicate-path "..") (define (regenerate!) diff --git a/syndicate/schema-compiler.rkt b/syndicate/schema-compiler.rkt new file mode 100644 index 0000000..effcfb5 --- /dev/null +++ b/syndicate/schema-compiler.rkt @@ -0,0 +1,15 @@ +#lang racket/base + +(provide schema-compiler-plugin) + +(require racket/match) +(require preserves-schema/compiler) + +(define (schema-compiler-plugin schema options) + (match-define (schema-compiler-options _name + lookup-module-path + paths) options) + (define ds-path (lookup-module-path '(dataspace-patterns))) + (if (equal? ds-path (schema-translation-paths-relative-output-path paths)) + `(begin) + `(begin (require (prefix-in :pat: ,ds-path))))) diff --git a/syndicate/schemas/dataspace-patterns.prs b/syndicate/schemas/dataspace-patterns.prs new file mode 100644 index 0000000..2740763 --- /dev/null +++ b/syndicate/schemas/dataspace-patterns.prs @@ -0,0 +1,11 @@ +version 1 . + +; Dataspace patterns: a sublanguage of attenuation patterns. +Pattern = DDiscard / DBind / DLit / DCompound . + +DDiscard = <_>. +DBind = . +DLit = . +DCompound = @rec @members { int: Pattern ...:... }> + / @arr @members { int: Pattern ...:... }> + / @dict @members { any: Pattern ...:... }> . diff --git a/syndicate/schemas/dataspace.prs b/syndicate/schemas/dataspace.prs index eadbd9a..3160df1 100644 --- a/syndicate/schemas/dataspace.prs +++ b/syndicate/schemas/dataspace.prs @@ -1,9 +1,4 @@ version 1 . embeddedType Actor.Ref . -;As implemented -Observe = . - -; ;As will be implemented soon -; Observe = . -. +Observe = . diff --git a/syndicate/schemas/gatekeeper.prs b/syndicate/schemas/gatekeeper.prs index 7673518..d8be377 100644 --- a/syndicate/schemas/gatekeeper.prs +++ b/syndicate/schemas/gatekeeper.prs @@ -1,5 +1,5 @@ version 1 . embeddedType Actor.Ref . -Resolve = . -Bind = . +Resolve = . +Bind = . diff --git a/syndicate/schemas/protocol.prs b/syndicate/schemas/protocol.prs index 1fe9c20..b86a66d 100644 --- a/syndicate/schemas/protocol.prs +++ b/syndicate/schemas/protocol.prs @@ -11,4 +11,4 @@ TurnEvent = [@oid Oid @event Event]. Assert = . Retract = . Message = . -Sync = . +Sync = . diff --git a/syndicate/schemas/secure-chat-protocol.prs b/syndicate/schemas/secure-chat-protocol.prs index 951e950..c20c8e0 100644 --- a/syndicate/schemas/secure-chat-protocol.prs +++ b/syndicate/schemas/secure-chat-protocol.prs @@ -3,9 +3,16 @@ embeddedType Actor.Ref . UserId = int . -Join = . +Join = . -NickClaim = . +Session = @observeUsers + / @observeSpeech + / NickClaim + / Says +. + +NickClaim = . +NickClaimResponse = #t / NickConflict . UserInfo = .