From 4d8a7c27ffec4dc303fef7b57d30cdef2651c825 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Tue, 5 Jan 2016 10:53:51 -0600 Subject: [PATCH] Simplify scrutinee parsing. --- 2d-lib/match.rkt | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/2d-lib/match.rkt b/2d-lib/match.rkt index d414404..8bbcc62 100644 --- a/2d-lib/match.rkt +++ b/2d-lib/match.rkt @@ -46,23 +46,15 @@ (with-syntax ([(left-x right-x) (generate-temporaries rhses)] [(first-arg second-arg) rhses]) (define-values (col-arg row-arg) - (cond [(< (syntax-column #'first-arg) - (syntax-column #'second-arg)) - ;; first argument is to the left, first is column - (values #'first-arg #'second-arg)] - [(= (syntax-column #'first-arg) - (syntax-column #'second-arg)) - ;; the two are aligned. second has to be below - ;; (otherwise it wouldn't be second), second is column - (unless (> (syntax-line #'second-arg) - (syntax-line #'first-arg)) - (error (format "2dmatch internal error: second is not below first: ~a ~a" - #'second-arg #'first-arg))) - (values #'second-arg #'first-arg)] - [else - ;; first to the right of second, whatever the line - ;; second is column - (values #'second-arg #'first-arg)])) + (if (< (syntax-column #'first-arg) + (syntax-column #'second-arg)) + ;; first argument is to the left of second, first is column + (values #'first-arg #'second-arg) + ;; otherwise, second argument is either aligned with first + ;; (in which case it's below, otherwise it wouldn't be second) + ;; or second is to the left of first + ;; either way, second is column + (values #'second-arg #'first-arg))) (set! let-bindings (list* #`[row-x #,row-arg] #`[col-x #,col-arg] let-bindings))