diff --git a/collects/datalog/lang/reader.rkt b/collects/datalog/lang/reader.rkt index 701c0c8..7394896 100644 --- a/collects/datalog/lang/reader.rkt +++ b/collects/datalog/lang/reader.rkt @@ -11,8 +11,22 @@ ; XXX Should have different comment character key (case key [(drracket:submit-predicate) - (dynamic-require `datalog/tool/submit 'repl-submit?)] + repl-submit?] [(color-lexer) (dynamic-require `datalog/tool/syntax-color 'get-syntax-token)] [else (default key defval)])) - (require "../parse.rkt")) \ No newline at end of file + (require datalog/parse + datalog/tool/submit) + + ; XXX This is almost certainly wrong. + (define (even-read src ip) + (begin0 + (parameterize ([current-source-name src]) + (datum->syntax #f (parse-statement ip))) + (current-read-interaction odd-read))) + (define (odd-read src ip) + (current-read-interaction even-read) + eof) + + (current-read-interaction + even-read)) \ No newline at end of file diff --git a/collects/datalog/parse.rkt b/collects/datalog/parse.rkt index 5c3f116..f846055 100644 --- a/collects/datalog/parse.rkt +++ b/collects/datalog/parse.rkt @@ -104,6 +104,7 @@ A Datalog reader consumes a Datalog program. A program is a sequence of zero or (define parse-program (mk-parser program-parser)) (provide/contract + [current-source-name (parameter/c any/c)] [parse-literal (input-port? . -> . literal?)] [parse-clause (input-port? . -> . clause?)] [parse-statement (input-port? . -> . statement/c)] diff --git a/collects/datalog/scribblings/datalog.scrbl b/collects/datalog/scribblings/datalog.scrbl index 415929e..6aebe6f 100644 --- a/collects/datalog/scribblings/datalog.scrbl +++ b/collects/datalog/scribblings/datalog.scrbl @@ -125,7 +125,9 @@ The following is a program: END ] -Currently, REPL interaction is not supported. +The Datalog REPL accepts new statements that are executed as if they were in the original program text. + +@include-section["tutorial.scrbl"] @section{Parenthetical Datalog Module Language} @(require (for-label datalog/sexp/lang)) @@ -152,6 +154,8 @@ The following is a program: (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. + @subsection[#:tag "parenstx"]{Parenthetical Syntax} @defmodule[datalog/sexp/lang] diff --git a/collects/datalog/scribblings/racket.scrbl b/collects/datalog/scribblings/racket.scrbl index 484bdd6..1c84a5c 100644 --- a/collects/datalog/scribblings/racket.scrbl +++ b/collects/datalog/scribblings/racket.scrbl @@ -197,6 +197,8 @@ This library provides facilities for parsing Datalog source. It can be required @defmodule[datalog/parse] +@defparam[current-source-name name any/c]{ A parameter used by the parsing functions to set the source name on the read ASTs. } + @defproc[(parse-literal [ip input-port?]) literal?]{ Parses a @racket[literal] from @racket[ip]. diff --git a/collects/datalog/scribblings/tutorial.scrbl b/collects/datalog/scribblings/tutorial.scrbl index 0bc80eb..e4c24bc 100644 --- a/collects/datalog/scribblings/tutorial.scrbl +++ b/collects/datalog/scribblings/tutorial.scrbl @@ -10,9 +10,11 @@ @title{Tutorial} -Start DrScheme and choose the @tt{Datalog} language from DrScheme's -@tt{Language} menu under @tt{Experimental Languages}. Click @onscreen{Run}, then -click in the REPL. +Start DrRacket and type + +@racketmod[datalog] + +in the Definitions window. Click @onscreen{Run}, then click in the REPL. @racketinput[] @@ -72,7 +74,7 @@ C is an ancestor of B, then A is an ancestor of B. #,(tt " parent(A, C),") #,(tt " ancestor(C, B).")] -In the interpreter, DrScheme knows that the clause is not complete, so by pressing Return, it doesn't interpret the line. +In the interpreter, DrRacket knows that the clause is not complete, so by pressing Return, it doesn't interpret the line. Rules are used to answer queries just as is done for facts.