Improves the error reporting and documentation for `define-relation'

This commit is contained in:
Casey Klein 2010-11-05 08:47:45 -05:00
parent 9a485064ed
commit 743ccafd15
3 changed files with 8 additions and 3 deletions

View File

@ -1462,7 +1462,7 @@
(when (null? (cdr more))
(raise-syntax-error syn-error-name
(format "expected a pattern to follow ~a" (syntax-e (car more)))
stx))
stx (car more)))
(loop (cddr more)
(cons (cadr more) arg-pats))]
[else
@ -1490,7 +1490,8 @@
[_
(raise-syntax-error
syn-error-name
"expected the name of the meta-function, followed by its contract (or no name and no contract)"
(format "expected the name of the ~a, followed by its contract (or no name and no contract)"
(if relation? "relation" "meta-function"))
stx
rest)])]))

View File

@ -1042,6 +1042,7 @@ and @racket[#f] otherwise.
@defform/subs[#:literals ()
(define-relation language
relation-contract
[(name @#,ttpattern ...) @#,tttterm ...] ...)
([relation-contract (code:line)
(code:line id ⊂ pat x ... x pat)

View File

@ -929,7 +929,10 @@
'failed)
'passed))
(test-syn-err
(define-relation grammar R)
#rx"expected the name of the relation")
; ;; ; ;; ;
; ; ; ; ;
; ;; ;; ;;; ;; ; ;; ;; ;;;; ;;;;; ;;; ;;; ;; ;; ;; ;; ;;; ; ;;; ;;;;; ;;; ;;; ;; ;;