Meta-Programming With Intensional Analysis
BibTeX
@MISC{Sheard_meta-programmingwith,
author = {Tim Sheard and Zine El-abidine Benaissa},
title = {Meta-Programming With Intensional Analysis},
year = {}
}
OpenURL
Abstract
syntax as an MetaMLdatatype declare x = 10 in -- x := x - 1; print x Sample program in concrete Syntax val S1 = Declare("x",Constant 10, Seq(Assign("x",Minus(Variable "x", Constant 1)), Print(Variable "y"))); Datatype encoding of sample program. !Do %mswo -- %push 10 ; a !- %read 1 ; b !- Return %mswo a %- 1 ; c !- %write 1 b ; d !- %read 1 ; e !- %output d ; Return %mswo () ; %pop ? Residual result of staging example program. (* interpret2 : Com -? index -? !unit M? *) fun interpret2 stmt index = case stmt of Assign(name,e) =? let val loc = position name index in !Do mswo -- n !- ~(eval2 e index) ; write ~(lift loc) n ? end --- Seq(s1,s2) =? !Do mswo -- x !- ~(interpret2 s1 index) ; y !- ~(interpret2 s2 index) ; Return mswo () ? --- Cond(e,s1,s2) =? !Do mswo -- x !- ~(eval2 e index) ; if x=1 then ~(interpret2 s1 index) else ~(interpret2 s2 index)? --- While(e,b) =? !let fun loop () = Do mswo -- v !- ~(eval2 e index) ; if v=0 then Return mswo...







