4.3BSD/usr/contrib/icon/test/buildt.icn

#  This program takes Icon expressions as input and outputs an Icon
#  program that tests the expressions, showing the expressions and
#  the results of evaluating them.

procedure main()
   local exp, lexp
   write("record array(a,b,c,d,e,f,g)")
   write("\nprocedure dummy(u,v,x,y,z)")
   write("   suspend u | v")
   write("   return x")
   write("end")
   write("\nprocedure main()")
   while exp := read() do {
      lexp := exp
      lexp ?:= escape()
      write("   write(\"",lexp," ----> \",image(",exp,") | \"none\")")
      }
   write("end")
end

procedure escape()
   local line
   line := ""
   while line ||:= tab(upto('"\\')) || "\\" || move(1)
   return line || tab(0)
end