Skip to content
Snippets Groups Projects
Commit f042cf13 authored by Claire GIROT--PERSON's avatar Claire GIROT--PERSON
Browse files

question 5.2

parent 47667739
No related branches found
No related tags found
No related merge requests found
open Ast
open BasicPfx.Ast
let generate = function
| Const _ -> failwith "To implement"
| Binop(_,_,_) -> failwith "To implement"
| Uminus _ -> failwith "To implement"
(* Question 5.2 *)
let rec generate = function
| Const x -> [Push x]
| Binop(Badd,a,b) -> (generate b) @ (generate a) @ [Add]
| Binop(Bsub,a,b) -> (generate b) @ (generate a) @ [Sub]
| Binop(Bmul,a,b) -> (generate b) @ (generate a) @ [Mul]
| Binop(Bdiv,a,b) -> (generate b) @ (generate a) @ [Div]
| Binop(Bmod,a,b) -> (generate b) @ (generate a) @ [Rem]
| Uminus x -> (generate x) @ [Push 0] @ [Sub]
| Var _ -> failwith "Not yet supported"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment