(define match-expr
(lambda (e em)
;; (println 'match-expr e 'em em)
(let ((var (variable-constructor em)))
(if (and (list? var) (not (null? var)) (not (string=? "literal" (cadddr var))))
(match-check-variable e var)
(cond ((symbol? e) (match-symbol e em))
((string? e) (match-string e em))
((number? e) (match-number e em))
((vector? e) (match-vector e em))
((list? e) (let ((res (match-list e em)))
(if (list? res)
(flatten res)
(list res))))
((pair? e) (match-pair e em))
(else MATCH-FAILED))))))