Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Microsoft.FSharp.Quotations.DerivedPatterns
- let rec toJava = function
- | Int32 x -> sprintf "%d" x
- | SpecificCall <@@ (+) @@> (None, _, [lhs;rhs]) -> sprintf "(%s+%s)" (toJava lhs) (toJava rhs)
- | _ -> failwith "Not supported"
- let toClass expr =
- sprintf """
- public class Generated {
- public static void main(String []args){
- System.out.println(%s);
- }
- }""" (toJava expr)
- toClass <@ 1 + 1 @>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement