From b126303628f4b1870094949558f89e587b044c97 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Sat, 26 Jun 2010 13:08:10 -0600 Subject: [PATCH] Protecting :- outside clauses --- collects/datalog/sexp/lang.rkt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/collects/datalog/sexp/lang.rkt b/collects/datalog/sexp/lang.rkt index 5aca47af6a..e85e850eb3 100644 --- a/collects/datalog/sexp/lang.rkt +++ b/collects/datalog/sexp/lang.rkt @@ -4,6 +4,9 @@ "../eval.rkt" "../ast.rkt") +(define-syntax (:- stx) + (raise-syntax-error ':- "only allowed inside ! and ~" stx)) + (define-syntax-parameter top (λ (stx) (raise-syntax-error '#%top "undefined identifier" stx))) (define-syntax-parameter unquote @@ -48,20 +51,14 @@ (define-syntax (->simple-clause stx) (syntax-case stx (:-) - [(_ (:- . r)) + [(_ (:- head body ...)) (quasisyntax/loc stx - (:- . r))] + (clause #'#,stx (->literal head) + (list (->literal body) ...)))] [(_ e) (quasisyntax/loc stx (clause #'#,stx (->literal e) empty))])) -(define-syntax (:- stx) - (syntax-case stx () - [(_ head body ...) - (quasisyntax/loc stx - (clause #'#,stx (->literal head) - (list (->literal body) ...)))])) - (define-syntax-rule (define-paren-stx op struct) (define-syntax (op stx) (syntax-case stx ()