fix and improve some syntax-error messages for `struct'
This commit is contained in:
parent
1d25f698da
commit
f05e6fa9c0
|
@ -41,7 +41,7 @@
|
||||||
(lambda (v stx)
|
(lambda (v stx)
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
#f
|
#f
|
||||||
"identifier for static struct-type information cannot be used as an expression"
|
"bad syntax;\n identifier for static struct-type information cannot be used as an expression"
|
||||||
stx))
|
stx))
|
||||||
null
|
null
|
||||||
(lambda (proc autos info)
|
(lambda (proc autos info)
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
(not (keyword? (syntax-e (car nps)))))
|
(not (keyword? (syntax-e (car nps)))))
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
#f
|
#f
|
||||||
(format "expected ~a ~a~a after keyword~a"
|
(format "bad syntax;\n expected ~a ~a~a after keyword~a"
|
||||||
orig-n
|
orig-n
|
||||||
(or what "expression")
|
(or what "expression")
|
||||||
(if (= orig-n 1) "" "s")
|
(if (= orig-n 1) "" "s")
|
||||||
|
@ -203,7 +203,7 @@
|
||||||
[_else
|
[_else
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
#f
|
#f
|
||||||
"expected a field identifier or a parenthesized identifier and field-specification sequence"
|
"bad syntax;\n expected a field identifier or a parenthesized identifier and field-specification sequence"
|
||||||
stx
|
stx
|
||||||
f)]))
|
f)]))
|
||||||
|
|
||||||
|
@ -244,8 +244,9 @@
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
#f
|
#f
|
||||||
(string-append
|
(string-append
|
||||||
"#:super specification disallowed because a struct supertype id"
|
"bad syntax;\n"
|
||||||
" was supplied with the struct type id")
|
" #:super specification disallowed because a struct supertype id was\n"
|
||||||
|
" supplied with the struct type id")
|
||||||
stx
|
stx
|
||||||
(car p)))
|
(car p)))
|
||||||
(loop (cddr p)
|
(loop (cddr p)
|
||||||
|
@ -344,7 +345,7 @@
|
||||||
(eq? '#:extra-constructor-name (syntax-e (car p))))
|
(eq? '#:extra-constructor-name (syntax-e (car p))))
|
||||||
(check-exprs 1 p "identifier")
|
(check-exprs 1 p "identifier")
|
||||||
(when (lookup config '#:constructor-name)
|
(when (lookup config '#:constructor-name)
|
||||||
(bad "multiple" "#:constructor-name or #:extra-constructor-name keys" (car p)))
|
(bad "multiple" "#:constructor-name or #:extra-constructor-name" "s" (car p)))
|
||||||
(unless (identifier? (cadr p))
|
(unless (identifier? (cadr p))
|
||||||
(bad "need an identifier after" (car p) (cadr p)))
|
(bad "need an identifier after" (car p) (cadr p)))
|
||||||
(loop (cddr p)
|
(loop (cddr p)
|
||||||
|
@ -402,7 +403,7 @@
|
||||||
[else
|
[else
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
#f
|
#f
|
||||||
"bad syntax; expected <id> for structure-type name or (<id> <id>) for name and supertype name"
|
"bad syntax;\n expected <id> for structure-type name or (<id> <id>) for name and supertype\n name"
|
||||||
stx
|
stx
|
||||||
#'id)]))])
|
#'id)]))])
|
||||||
(let-values ([(super-info super-autos super-info-checked?)
|
(let-values ([(super-info super-autos super-info-checked?)
|
||||||
|
@ -418,8 +419,7 @@
|
||||||
#f
|
#f
|
||||||
(format "parent struct type not defined~a"
|
(format "parent struct type not defined~a"
|
||||||
(if v
|
(if v
|
||||||
(format " (~a does not name struct type information)"
|
";\n identifier does not name struct type information"
|
||||||
(syntax-e super-id))
|
|
||||||
""))
|
""))
|
||||||
stx
|
stx
|
||||||
super-id)))
|
super-id)))
|
||||||
|
@ -681,7 +681,7 @@
|
||||||
(andmap identifier? (syntax->list #'id)))))
|
(andmap identifier? (syntax->list #'id)))))
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
#f
|
#f
|
||||||
"bad syntax; expected <id> for structure-type name or (<id> <id>) for name and supertype name"
|
"bad syntax;\n expected <id> for structure-type name or (<id> <id>) for name and supertype\n name"
|
||||||
stx
|
stx
|
||||||
#'id)]
|
#'id)]
|
||||||
[(_ _ id (field ...) . _)
|
[(_ _ id (field ...) . _)
|
||||||
|
@ -694,13 +694,13 @@
|
||||||
[(_ _ id fields . _)
|
[(_ _ id fields . _)
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
#f
|
#f
|
||||||
"bad syntax; expected a parenthesized sequence of field descriptions"
|
"bad syntax;\n expected a parenthesized sequence of field descriptions"
|
||||||
stx
|
stx
|
||||||
#'fields)]
|
#'fields)]
|
||||||
[(_ _ id)
|
[(_ _ id)
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
#f
|
#f
|
||||||
"bad syntax; missing fields"
|
"bad syntax;\n missing fields"
|
||||||
stx)]
|
stx)]
|
||||||
[_
|
[_
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
|
@ -738,7 +738,10 @@
|
||||||
#'field))]
|
#'field))]
|
||||||
[_
|
[_
|
||||||
(raise-syntax-error #f
|
(raise-syntax-error #f
|
||||||
"expected a field update of the form (<field-id> <expr>) or (<field-id> #:parent <parent-id> <expr>)"
|
(string-append
|
||||||
|
"bad syntax;\n"
|
||||||
|
" expected a field update of the form (<field-id> <expr>)\n"
|
||||||
|
" or (<field-id> #:parent <parent-id> <expr>)")
|
||||||
stx
|
stx
|
||||||
an)]))
|
an)]))
|
||||||
ans)
|
ans)
|
||||||
|
|
|
@ -40,5 +40,5 @@
|
||||||
[(_ thing . _)
|
[(_ thing . _)
|
||||||
(raise-syntax-error #f
|
(raise-syntax-error #f
|
||||||
"expected an identifier for the structure type name"
|
"expected an identifier for the structure type name"
|
||||||
#'thing
|
stx
|
||||||
stx)]))))
|
#'thing)]))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user