Question on nested expressions

22 views
Skip to first unread message

Shiwei Weng

unread,
Dec 4, 2017, 11:48:34 PM12/4/17
to nanopass-framework
Hi all, I write a simple example for my question.

If I want to keep the Expr to be (e* ... e), then 
in the `de-Expr`, is there any way to deal with `e*` and `e0` together, 

(I hope code similar to `(map de-Expr (append e* (list e0))` but I try several ways, neither of them works.

```racket
#lang nanopass

(define-language L
  (Expr (e)
    (e* ... e)
    (ok f))
  (Foo (f)
    (bar)
    (boo)))

(define-pass bar-boo : L(e) -> L ()
  (de-Expr : Expr (e env) -> Expr ()
    [(,e* ... ,e0)
     (let* ([ne* (map de-Expr e*)
             [ne0 (de-Expr e0)])
       `(,ne* ... ,ne0))]
    [(ok ,[f])
     `(ok ,f)])
   (de-bar : Foo (f) -> Foo ()
    [(bar)
     `(boo)])
)

(define-parser parse-L L)

(bar-boo
 (parse-L
  `(
    (ok (bar))
    (ok (bar))
    (ok (bar))
    )
  )
)
```

best,
shiwei

Reply all
Reply to author
Forward
0 new messages