#lang nanopass
(define-language example (terminals (symbol (s))) (Expr (e) (s0 ((s1 s2) ...))))example.rkt> (define-parser p example)example.rkt> (p '(test ((a b) (c d))))(language:example '(test ((a b) (c d))))(with-output-language (example Expr) (let ([symbol-list '((a b) (c d))]) `(test ,symbol-list))); stdin::27080: test: invalid pattern or template ; in: (test (unquote symbol-list)) (with-output-language (example Expr) `(test ((a b) (c d))))When you are using with-output-language (or in the body of a pass), the nanopass framework does not attempt to parse s-expressions into the underlying Racket struct types, it looks for each field to be separately specified. So, the form: (s0 ((s1 s2) …) is represented by a struct with three fields: s0, s1, and s2 where s0 is a symbol and s1 and s2 are both lists of symbols. So you have to break the symbol-list down into the s1 list and the s2 list:
(with-output-language (example Expr)
(let ([symbol-list '((a b) (c d))])
`(test ((,(map car symbol-list) ,(map cadr symbol-list)) ...))))
Note that the … is also needed.
-andy:)
--
You received this message because you are subscribed to the Google Groups "nanopass-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanopass-framew...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nanopass-framework/46b02987-6f4b-4d02-b930-5703c061d016%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nanopass-framework/CANbdEPrn20rwAs8SGKToh_szZx%2B2wmxkrj7JXEiJ9fuwaM%3DfNw%40mail.gmail.com.
Hey Jens,with-output-language is intentionally a splicing form (so it does not wrap the contents in a (let () …)).