Improved handling of syntax errors in `reduction-relation'

svn: r18431
This commit is contained in:
Casey Klein 2010-03-02 19:00:55 +00:00
parent ef9de6517a
commit d82fdbc317
2 changed files with 30 additions and 0 deletions

View File

@ -485,6 +485,20 @@
[withs (make-module-identifier-mapping)])
(for-each (λ (shortcut)
(syntax-case shortcut ()
[((rhs-arrow rhs-from rhs-to)
(lhs-arrow a b))
(not (identifier? #'a))
(raise-syntax-error
orig-name
"malformed shortcut, expected identifier"
shortcut #'a)]
[((rhs-arrow rhs-from rhs-to)
(lhs-arrow a b))
(not (identifier? #'b))
(raise-syntax-error
orig-name
"malformed shortcut, expected identifier"
shortcut #'b)]
[((rhs-arrow rhs-from rhs-to)
(lhs-arrow lhs-from lhs-to))
(begin

View File

@ -1090,6 +1090,22 @@
[(~> a b) (==> a b)])
#rx"~> relation is not defined")
(test-syn-err (reduction-relation
grammar
(==> 1 2)
with
[(--> a b)
(==> a (+ 3 b))])
#rx"expected identifier")
(test-syn-err (reduction-relation
grammar
(==> 1 2)
with
[(--> a b)
(==> (+ 3 a) b)])
#rx"expected identifier")
(test-syn-err (define-language bad-lang1 (e name)) #rx"name")
(test-syn-err (define-language bad-lang2 (name x)) #rx"name")
(test-syn-err (define-language bad-lang3 (x_y x)) #rx"cannot have _")