From a4f70ae598029e75d1ac12d01b63e98ca2140e9b Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Mon, 8 Aug 2011 11:55:49 -0600 Subject: [PATCH] Fixing PR12085 --- collects/racklog/lang/configure-runtime.rkt | 20 ++++++++++++++++++++ collects/racklog/lang/lang-info.rkt | 10 ++++++++++ collects/racklog/lang/reader.rkt | 17 +++-------------- collects/tests/racklog/pr/pr12085.rkt | 15 +++++++++++++++ 4 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 collects/racklog/lang/configure-runtime.rkt create mode 100644 collects/racklog/lang/lang-info.rkt create mode 100644 collects/tests/racklog/pr/pr12085.rkt diff --git a/collects/racklog/lang/configure-runtime.rkt b/collects/racklog/lang/configure-runtime.rkt new file mode 100644 index 0000000000..15e7164b51 --- /dev/null +++ b/collects/racklog/lang/configure-runtime.rkt @@ -0,0 +1,20 @@ +#lang racket/base + +(define (configure data) + ;; (printf "Configuring\n") + (current-read-interaction even-read)) +(provide configure) + +(require datalog/parse + racklog/lang/compiler) + +; XXX This is almost certainly wrong. +(define (even-read src ip) + (begin0 + (compile-statement + (parameterize ([current-source-name src]) + (parse-statement ip))) + (current-read-interaction odd-read))) +(define (odd-read src ip) + (current-read-interaction even-read) + eof) diff --git a/collects/racklog/lang/lang-info.rkt b/collects/racklog/lang/lang-info.rkt new file mode 100644 index 0000000000..ebde9a2927 --- /dev/null +++ b/collects/racklog/lang/lang-info.rkt @@ -0,0 +1,10 @@ +#lang racket/base + +(define (get-info data) + (λ (key default) + (case key + [(configure-runtime) + '(#(racklog/lang/configure-runtime configure #f))] + [else + default]))) +(provide get-info) diff --git a/collects/racklog/lang/reader.rkt b/collects/racklog/lang/reader.rkt index 738a7a8606..c1858dbec6 100644 --- a/collects/racklog/lang/reader.rkt +++ b/collects/racklog/lang/reader.rkt @@ -4,6 +4,8 @@ #:read (lambda ([in (current-input-port)]) (this-read-syntax #f in)) #:read-syntax this-read-syntax #:whole-body-readers? #t + #:language-info + '#(racklog/lang/lang-info get-info #f) #:info (lambda (key defval default) ; XXX Should have different comment character key (case key @@ -11,8 +13,6 @@ (dynamic-require 'datalog/tool/submit 'repl-submit?)] [(color-lexer) (dynamic-require 'datalog/tool/syntax-color 'get-syntax-token)] - [(configure-runtime) - (λ () (current-read-interaction even-read))] [else (default key defval)])) (require datalog/parse racklog/lang/compiler) @@ -21,15 +21,4 @@ (list (compile-program (parameterize ([current-source-name src]) - (parse-program in))))) - - ; XXX This is almost certainly wrong. - (define (even-read src ip) - (begin0 - (compile-statement - (parameterize ([current-source-name src]) - (parse-statement ip))) - (current-read-interaction odd-read))) - (define (odd-read src ip) - (current-read-interaction even-read) - eof)) + (parse-program in)))))) diff --git a/collects/tests/racklog/pr/pr12085.rkt b/collects/tests/racklog/pr/pr12085.rkt new file mode 100644 index 0000000000..28037022d4 --- /dev/null +++ b/collects/tests/racklog/pr/pr12085.rkt @@ -0,0 +1,15 @@ +#lang racklog + +% Run parent_child(P,C)? + +mother_child(trude, sally). + +father_child(tom, sally). +father_child(tom, erica). +father_child(mike, tom). + +sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y). + +parent_child(X, Y) :- father_child(X, Y). +parent_child(X, Y) :- mother_child(X, Y). +