Fixing datalog tests broken by bf95ee105

This commit is contained in:
Jay McCarthy 2012-06-01 17:25:00 -06:00
parent fc8cb6e37d
commit 7d506713dd
2 changed files with 20 additions and 10 deletions

View File

@ -11,8 +11,16 @@
(or/c exact-nonnegative-integer? #f)
(or/c exact-positive-integer? #f))))
(define datum/c (or/c string? symbol?))
(define datum-equal? equal?)
(define-struct predicate-sym (srcloc sym) #:prefab)
(define datum/c (or/c string? symbol? predicate-sym?))
(define (datum-equal? x y)
(match* (x y)
[((predicate-sym _ x) y)
(datum-equal? x y)]
[(x (predicate-sym _ y))
(datum-equal? x y)]
[(x y)
(equal? x y)]))
(define-struct variable (srcloc sym) #:prefab)
(define (variable-equal? v1 v2)
@ -21,8 +29,6 @@
(define (constant-equal? v1 v2)
(equal? (constant-value v1) (constant-value v2)))
(define-struct predicate-sym (srcloc sym) #:prefab)
(define term/c (or/c variable? constant?))
(define (term-equal? t1 t2)
(cond

View File

@ -5,12 +5,16 @@
"private/pprint.rkt"
"ast.rkt")
(define (format-datum s)
(cond
[(symbol? s)
(text (symbol->string s))]
[else
(text (format "~S" s))]))
(define format-datum
(match-lambda
[(predicate-sym _ s)
(format-datum s)]
[(? symbol? s)
(text (symbol->string s))]
[(? string? s)
(text (format "~S" s))]
[(? number? s)
(text (format "~S" s))]))
(define (format-variable v)
(format-datum (variable-sym v)))
(define (format-constant c)