diff --git a/collects/datalog/scribblings/datalog.scrbl b/collects/datalog/scribblings/datalog.scrbl index 6aebe6f6b7..7f0a49fcf3 100644 --- a/collects/datalog/scribblings/datalog.scrbl +++ b/collects/datalog/scribblings/datalog.scrbl @@ -136,9 +136,7 @@ The Datalog REPL accepts new statements that are executed as if they were in the The semantics of this language is the same as the normal Datalog language, except it uses a @secref["parenstx"]. -Literals are represented as S-expressions with identifiers for constant symbols, strings for constant strings, and @racket[,id] for variable symbols. - -@racket[unquote], top-level identifiers, and strings are not otherwise allowed in the program. +Literals are represented as S-expressions with non-capitalized identifiers for constant symbols, strings for constant strings, and capitalized identifiers for variable symbols. Top-level identifiers and strings are not otherwise allowed in the program. The following is a program: @racketmod[datalog/sexp @@ -147,12 +145,12 @@ The following is a program: (! (edge b c)) (! (edge c d)) (! (edge d a)) -(! (:- (path ,X ,Y) - (edge ,X ,Y))) -(! (:- (path ,X ,Y) - (edge ,X ,Z) - (path ,Z ,Y))) -(? (path ,X ,Y))] +(! (:- (path X Y) + (edge X Y))) +(! (:- (path X Y) + (edge X Z) + (path Z Y))) +(? (path X Y))] The Parenthetical Datalog REPL accepts new statements that are executed as if they were in the original program text. @@ -168,8 +166,6 @@ The Parenthetical Datalog REPL accepts new statements that are executed as if th @defform[(= term term)]{ An equality literal. } -@defform[(unquote symbol)]{ A variable symbol. } - @include-section["racket.scrbl"] @section{Acknowledgments} diff --git a/collects/datalog/sexp/lang.rkt b/collects/datalog/sexp/lang.rkt index e85e850eb3..c1fc06688a 100644 --- a/collects/datalog/sexp/lang.rkt +++ b/collects/datalog/sexp/lang.rkt @@ -9,8 +9,6 @@ (define-syntax-parameter top (λ (stx) (raise-syntax-error '#%top "undefined identifier" stx))) -(define-syntax-parameter unquote - (λ (stx) (raise-syntax-error 'unquote "only allowed inside literals" stx))) (define-syntax-parameter datum (λ (stx) (raise-syntax-error '#%datum "only allowed inside literals" stx))) @@ -18,15 +16,11 @@ (syntax-parse stx [(_ . sym:id) - (quasisyntax/loc stx - (constant #'#,stx 'sym))])) - -(define-syntax (literal-unquote stx) - (syntax-parse - stx - [(_ sym:id) - (quasisyntax/loc stx - (variable #'#,stx 'sym))])) + (if (char-upper-case? (string-ref (symbol->string (syntax->datum #'sym)) 0)) + (quasisyntax/loc stx + (variable #'#,stx 'sym)) + (quasisyntax/loc stx + (constant #'#,stx 'sym)))])) (define-syntax (literal-datum stx) (syntax-parse @@ -45,8 +39,7 @@ (quasisyntax/loc stx (literal #'#,stx 'sym (syntax-parameterize ([top (make-rename-transformer #'literal-top)] - [datum (make-rename-transformer #'literal-datum)] - [unquote (make-rename-transformer #'literal-unquote)]) + [datum (make-rename-transformer #'literal-datum)]) (list e ...))))])) (define-syntax (->simple-clause stx) @@ -84,5 +77,4 @@ #%top-interaction #%module-begin ! ~ ? - :- = - unquote) \ No newline at end of file + :- =) \ No newline at end of file diff --git a/collects/tests/datalog/paren-examples/ancestor.rkt b/collects/tests/datalog/paren-examples/ancestor.rkt index 78e5f87188..290994b776 100644 --- a/collects/tests/datalog/paren-examples/ancestor.rkt +++ b/collects/tests/datalog/paren-examples/ancestor.rkt @@ -1,12 +1,12 @@ #lang datalog/sexp ; Equality test -(! (:- (ancestor ,A ,B) - (parent ,A ,B))) -(! (:- (ancestor ,A ,B) - (parent ,A ,C) +(! (:- (ancestor A B) + (parent A B))) +(! (:- (ancestor A B) + (parent A C) (= D C) ; Unification required - (ancestor ,D ,B))) + (ancestor D B))) (! (parent john douglas)) (! (parent bob john)) (! (parent ebbon bob)) -(? (ancestor ,A ,B)) +(? (ancestor A B)) diff --git a/collects/tests/datalog/paren-examples/ancestor.txt b/collects/tests/datalog/paren-examples/ancestor.txt index 27724bbbfb..bed107f84b 100644 --- a/collects/tests/datalog/paren-examples/ancestor.txt +++ b/collects/tests/datalog/paren-examples/ancestor.txt @@ -1,6 +1,6 @@ -ancestor(ebbon, douglas). -ancestor(ebbon, john). -ancestor(bob, douglas). ancestor(ebbon, bob). ancestor(bob, john). ancestor(john, douglas). +ancestor(bob, douglas). +ancestor(ebbon, john). +ancestor(ebbon, douglas). diff --git a/collects/tests/datalog/paren-examples/bidipath.rkt b/collects/tests/datalog/paren-examples/bidipath.rkt index 9582561db7..5c32fbb191 100644 --- a/collects/tests/datalog/paren-examples/bidipath.rkt +++ b/collects/tests/datalog/paren-examples/bidipath.rkt @@ -4,12 +4,12 @@ (! (edge b c)) (! (edge c d)) (! (edge d a)) -(! (:- (path ,X ,Y) - (edge ,X ,Y))) -(! (:- (path ,X ,Y) - (edge ,X ,Z) - (path ,Z ,Y))) -(! (:- (path ,X ,Y) - (path ,X ,Z) - (edge ,Z ,Y))) -(? (path ,X ,Y)) \ No newline at end of file +(! (:- (path X Y) + (edge X Y))) +(! (:- (path X Y) + (edge X Z) + (path Z Y))) +(! (:- (path X Y) + (path X Z) + (edge Z Y))) +(? (path X Y)) \ No newline at end of file diff --git a/collects/tests/datalog/paren-examples/laps.rkt b/collects/tests/datalog/paren-examples/laps.rkt index 4bf83043e9..66b38a9828 100644 --- a/collects/tests/datalog/paren-examples/laps.rkt +++ b/collects/tests/datalog/paren-examples/laps.rkt @@ -2,12 +2,12 @@ ; Laps Test (! (contains ca store rams_couch rams)) (! (contains rams fetch rams_couch will)) -(! (:- (contains ca fetch ,Name ,Watcher) - (contains ca store ,Name ,Owner) - (contains ,Owner fetch ,Name ,Watcher))) +(! (:- (contains ca fetch Name Watcher) + (contains ca store Name Owner) + (contains Owner fetch Name Watcher))) (! (trusted ca)) -(! (:- (permit ,User ,Priv ,Name) - (contains ,Auth ,Priv ,Name ,User) - (trusted ,Auth))) -(? (permit ,User ,Priv ,Name)) +(! (:- (permit User Priv Name) + (contains Auth Priv Name User) + (trusted Auth))) +(? (permit User Priv Name)) diff --git a/collects/tests/datalog/paren-examples/path.rkt b/collects/tests/datalog/paren-examples/path.rkt index 31de89cb29..ba2768e2cc 100644 --- a/collects/tests/datalog/paren-examples/path.rkt +++ b/collects/tests/datalog/paren-examples/path.rkt @@ -4,9 +4,9 @@ (! (edge b c)) (! (edge c d)) (! (edge d a)) -(! (:- (path ,X ,Y) - (edge ,X ,Y))) -(! (:- (path ,X ,Y) - (edge ,X ,Z) - (path ,Z ,Y))) -(? (path ,X ,Y)) +(! (:- (path X Y) + (edge X Y))) +(! (:- (path X Y) + (edge X Z) + (path Z Y))) +(? (path X Y)) diff --git a/collects/tests/datalog/paren-examples/pq.rkt b/collects/tests/datalog/paren-examples/pq.rkt index 1c08e17f80..fb0a3eccb6 100644 --- a/collects/tests/datalog/paren-examples/pq.rkt +++ b/collects/tests/datalog/paren-examples/pq.rkt @@ -1,8 +1,8 @@ #lang datalog/sexp ; p q test from Chen & Warren -(! (:- (q ,X) - (p ,X))) +(! (:- (q X) + (p X))) (! (q a)) -(! (:- (p ,X) - (q ,X))) -(? (q ,X)) +(! (:- (p X) + (q X))) +(? (q X)) diff --git a/collects/tests/datalog/paren-examples/revpath.rkt b/collects/tests/datalog/paren-examples/revpath.rkt index 33cc2385ab..5899cdf639 100644 --- a/collects/tests/datalog/paren-examples/revpath.rkt +++ b/collects/tests/datalog/paren-examples/revpath.rkt @@ -4,9 +4,9 @@ (! (edge b c)) (! (edge c d)) (! (edge d a)) -(! (:- (path ,X ,Y) - (edge ,X ,Y))) -(! (:- (path ,X ,Y) - (path ,X ,Z) - (edge ,Z ,Y))) -(? (path ,X ,Y)) \ No newline at end of file +(! (:- (path X Y) + (edge X Y))) +(! (:- (path X Y) + (path X Z) + (edge Z Y))) +(? (path X Y)) \ No newline at end of file diff --git a/collects/tests/datalog/paren-examples/says.rkt b/collects/tests/datalog/paren-examples/says.rkt index 1c10fb071a..90c7f71e9b 100644 --- a/collects/tests/datalog/paren-examples/says.rkt +++ b/collects/tests/datalog/paren-examples/says.rkt @@ -1,7 +1,7 @@ #lang datalog/sexp (! (tpme tpme1)) (! (ms m1 "TPME" tpme1 ek tp)) -(! (:- (says ,TPME ,M) - (tpme ,TPME) - (ms ,M "TPME" ,TPME ,A ,B))) -(? (says ,A ,B)) +(! (:- (says TPME M) + (tpme TPME) + (ms M "TPME" TPME A B))) +(? (says A B)) diff --git a/collects/tests/datalog/paren-examples/tutorial.rkt b/collects/tests/datalog/paren-examples/tutorial.rkt index 90e1d6cc22..6d51ed6749 100644 --- a/collects/tests/datalog/paren-examples/tutorial.rkt +++ b/collects/tests/datalog/paren-examples/tutorial.rkt @@ -6,23 +6,23 @@ (! (parent bob john)) (! (parent ebbon bob)) -(? (parent ,A ,B)) +(? (parent A B)) -(? (parent john ,B)) +(? (parent john B)) -(? (parent ,A ,A)) +(? (parent A A)) -(! (:- (ancestor ,A ,B) - (parent ,A ,B))) -(! (:- (ancestor ,A ,B) - (parent ,A ,C) - (ancestor ,C ,B))) -(? (ancestor ,A ,B)) +(! (:- (ancestor A B) + (parent A B))) +(! (:- (ancestor A B) + (parent A C) + (ancestor C B))) +(? (ancestor A B)) -(? (ancestor ,X john)) +(? (ancestor X john)) (~ (parent bob john)) -(? (parent ,A ,B)) +(? (parent A B)) -(? (ancestor ,A ,B)) +(? (ancestor A B))