Removing old sexp library and correct docs for warning

This commit is contained in:
Jay McCarthy 2010-06-25 22:04:55 -06:00
parent e90de7196d
commit 0bda9efa96
5 changed files with 3 additions and 161 deletions

View File

@ -1,13 +1,11 @@
#lang racket
(require "ast.rkt"
"parse.rkt"
"sexp.rkt"
"pretty.rkt"
"runtime.rkt"
"eval.rkt")
(provide (all-from-out "ast.rkt"
"parse.rkt"
"sexp.rkt"
"pretty.rkt"
"runtime.rkt"
"eval.rkt"))

View File

@ -10,7 +10,7 @@
@title{Racket Interoperability}
@defmodule[datalog]
@defmodule[datalog/main]
The Datalog database can be directly used by Racket programs through this API.
@ -253,39 +253,6 @@ This library provides facilities for parsing Datalog source. It can be required
"path(X, Y)?")))]
}
@section{Parenthetical Datalog Parsing}
This package recognizes an alternative, Scheme-like front-end syntax for Datalog. It can be required via:
@defmodule[datalog/sexp]
@defproc[(stx->term [stx syntax?])
term/c]{
Parses @racket[stx] as a @tech{term}.
}
@defproc[(stx->literal [stx syntax?])
literal?]{
Parses @racket[stx] as a @racket[literal].
}
@defproc[(stx->clause [stx syntax?])
clause?]{
Parses @racket[stx] as a @racket[clause].
}
@defproc[(stx->statement [stx syntax?])
statement/c]{
Parses @racket[stx] as a @tech{statement}.
}
@defproc[(stx->program [stx syntax?])
program/c]{
Parses @racket[stx] as a @tech{program}.
}
@defproc[(sexp->term [sexp sexpr?]) term/c]{@racket[stx->term] composed with @racket[datum->syntax].}
@defproc[(sexp->literal [sexp sexpr?]) literal?]{@racket[stx->literal] composed with @racket[datum->syntax].}
@defproc[(sexp->clause [sexp sexpr?]) clause?]{@racket[stx->clause] composed with @racket[datum->syntax].}
@defproc[(sexp->statement [sexp sexpr?]) statement/c]{@racket[stx->statement] composed with @racket[datum->syntax].}
@defproc[(sexp->program [sexp sexpr?]) program/c]{@racket[stx->program] composed with @racket[datum->syntax].}
@section{Pretty-Printing}
This library provides facilities for pretty-printing Datalog source. It can be required via:

View File

@ -1,72 +0,0 @@
#lang racket
(require "ast.rkt")
(define sexpr? any/c)
(define (sexp-wrap s->)
(lambda (sexp)
(s-> (datum->syntax #f sexp #f))))
(define (stx->program stx)
(syntax-case stx (begin)
[(begin s ...)
(map stx->statement (syntax->list #'(s ...)))]))
(define sexp->program (sexp-wrap stx->program))
(define (stx->statement stx)
(syntax-case stx (! ~ ?)
[(! c)
(make-assertion stx (stx->clause #'c))]
[(~ c)
(make-retraction stx (stx->clause #'c))]
[(? l)
(make-query stx (stx->literal #'l))]))
(define sexp->statement (sexp-wrap stx->statement))
(define (stx->clause stx)
(syntax-case stx (:-)
[(:- l body ...)
(make-clause stx (stx->literal #'l)
(map stx->literal (syntax->list #'(body ...))))]
[l
(make-clause stx (stx->literal #'l) empty)]))
(define sexp->clause (sexp-wrap stx->clause))
(define (stx->literal stx)
(syntax-case stx ()
[(p t ...)
(make-literal
stx (stx->datum #'p)
(map stx->term (syntax->list #'(t ...))))]))
(define sexp->literal (sexp-wrap stx->literal))
(define (stx->term stx)
(syntax-case stx (unquote)
[(unquote d)
(identifier? #'d)
(make-variable stx (syntax->datum #'d))]
[d
(datum-syntax? #'d)
(make-constant stx (stx->datum #'d))]))
(define sexp->term (sexp-wrap stx->term))
(define (datum-syntax? stx)
(define d (syntax->datum stx))
(or (symbol? d) (string? d)))
(define (stx->datum stx)
(syntax-case stx ()
[d
(datum-syntax? #'d)
(syntax->datum #'d)]))
(provide/contract
[stx->program (syntax? . -> . program/c)]
[stx->statement (syntax? . -> . statement/c)]
[stx->clause (syntax? . -> . clause?)]
[stx->literal (syntax? . -> . literal?)]
[stx->term (syntax? . -> . term/c)]
[sexp->program (sexpr? . -> . program/c)]
[sexp->statement (sexpr? . -> . statement/c)]
[sexp->clause (sexpr? . -> . clause?)]
[sexp->literal (sexpr? . -> . literal?)]
[sexp->term (sexpr? . -> . term/c)])

View File

@ -5,8 +5,7 @@
"private/lex.rkt"
"tool/syntax-color.rkt"
"parse.rkt"
"sexp.rkt"
"parse.rkt"
"pretty.rkt"
@ -26,8 +25,7 @@
lex-tests
syntax-color-tests
parse-tests
sexp-tests
parse-tests
pretty-tests

View File

@ -1,49 +0,0 @@
#lang racket
(require rackunit
datalog/ast
datalog/sexp
"util.rkt")
(provide sexp-tests)
(define test
#'(begin
(! (parent john douglas))
(? (parent john douglas))
(? (parent john ebbon))
(! (parent bob john))
(! (parent ebbon bob))
(? (parent ,A ,B))
(? (parent john ,B))
(? (parent ,A ,A))
(! (:- (ancestor ,A ,B)
(parent ,A ,B)))
(! (:- (ancestor ,A ,B)
(parent ,A ,C)
(ancestor ,C ,B)))
(? (ancestor ,A ,B))
(? (ancestor ,X john))
(~ (parent bob john))
(? (parent ,A ,B))
(? (ancestor ,A ,B))))
(define sexp-tests
(test-suite
"sexp"
(test-not-exn "program" (lambda () (contract program/c (stx->program test) 'pos 'neg)))
(test-not-false "stmt" (assertion? (stx->statement #'(! (parent john douglas)))))
(test-not-false "stmt" (retraction? (stx->statement #'(~ (parent john douglas)))))
(test-not-false "stmt" (query? (stx->statement #'(? (parent john douglas)))))
(test-clause "clause" (stx->clause #'(parent john douglas))
(make-clause #f (make-literal #f 'parent (list (make-constant #f 'john) (make-constant #f 'douglas))) empty))
(test-clause "clause" (stx->clause #'(:- (ancestor ,A ,B) (parent ,A ,B)))
(make-clause #f (make-literal #f 'ancestor (list (make-variable #f 'A) (make-variable #f 'B)))
(list (make-literal #f 'parent (list (make-variable #f 'A) (make-variable #f 'B))))))
(test-literal "literal" (stx->literal #'(parent john douglas))
(make-literal #f 'parent (list (make-constant #f 'john) (make-constant #f 'douglas))))
))