* quasiquoting and pattern matches
@ 2009-04-17 17:25 Joel Reymont
0 siblings, 0 replies; only message in thread
From: Joel Reymont @ 2009-04-17 17:25 UTC (permalink / raw)
To: O'Caml Mailing List
There's an example in the Geoffrey Mainland's Haskell
quasiquotation paper [1] that looks like this:
peep :: [ Asm ] -> [ Asm ]
peep [:asm| mov&s $&r1, &r2
cmp $&r3, &r4
je &lbl |] : rest
| r3 = r1 ^ r4 = r2
= [:asm| mov&s $&r1, &r2
jmp &lbl |] : rest
...
Is it possible to do the same in OCaml, i.e. use
antiquotations in pattern matches?
I have not seen it done this way before, all the
examples match the AST, e.g. from jsgen.ml
let compile_implementation modulename expr =
let ce =
match expr with
| Lprim (Psetglobal id, [e]) ->
enter_setglobal id;
<:stmt< var $id:jsident_of_ident id$ = $comp_expr false e$;
>>
| _ -> unimplemented "compile_implementation" expr in
let ret = (ce, !reloc_info) in
reloc_info := [];
ret
Thanks, Joel
[1] http://www.eecs.harvard.edu/~mainland/ghc-quasiquoting/
---
Mac hacker with a performance bent
http://linkedin.com/in/joelreymont
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-04-17 17:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-17 17:25 quasiquoting and pattern matches Joel Reymont
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox