Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let pushNum i =
- match i with
- | IntVal x -> "ldc.i4.s " + string x
- | _ -> failwith "Syntax error"
- let rec compile expr =
- match expr with
- | ConstInt i -> pushNum (IntVal i)
- | PrimOp ("+", lOper, rOper) -> evalNumericExpr (+) lOper rOper
- //| PrimOp ("-", lOper, rOper) -> evalNumericExpr (-) lOper rOper
- //| PrimOp ("*", lOper, rOper) -> evalNumericExpr (*) lOper rOper
- //| PrimOp ("/", lOper, rOper) -> evalNumericExpr (/) lOper rOper
- //| PrimOp ("%", lOper, rOper) -> evalNumericExpr (%) lOper rOper
- | _ -> failwith "Syntax error"
- and evalNumericExpr op lOper rOper =
- let left = compile lOper
- let right = compile rOper
- match (op) with
- | (+) -> "ADD"
- | _ -> failwith "Syntax error"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement