Closed dannypsnl closed 1 year ago
The idea of recur-match* is to write a code like
recur-match*
(struct Expr ()) (struct Int Expr ([val : Integer])) (struct Add Expr ([left : Expr] [right : Expr])) (define-language L0 (terminals (Integer (n))) (Expr (e) ,n (Add ,e ,e))) (define-language L1 (Prog () ,@i) (Instruction (i) ...)) (: compile-expr : L0:Expr -> L1:Prog) (define (compile-expr e) (recur-match* e #:lang L0 #:on compile-expr [,n (list (mov 'x0 n))] [(Add ,[l] ,[r]) `(,@l ,(mov 'x1 'x0) ,@r ,(add 'x0 'x1))]))
#:lang
#:on
,[x]
match*
Add ,[e0] ,[e1]
The idea of
recur-match*
is to write a code like#:lang
spec the language, so it can get meta information to generate some code automatically.#:on
keyword spec the recursive function for,[x]
pattern.match*
stands for matching several terms at once, it would be convenient for type checking.Problems here
Add ,[e0] ,[e1]
, would this make problems in the future? I have no idea.