Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. open Tfbsrxast;;
  2. open Tfbsrxpp;;
  3.  
  4. (*
  5. * If you would like typechecking to be enabled by your interpreter by default,
  6. * then change the following value to true. Whether or not typechecking is
  7. * enabled by default, you can explicitly enable it or disable it using
  8. * command-line arguments.
  9. *)
  10. let typecheck_default_enabled = true;;
  11.  
  12. (*
  13. * Replace this with your typechecker code. Your code should not throw the
  14. * following exception; if you need to raise an exception, create your own
  15. * exception type here.
  16. *)
  17.  
  18. let rec baby_typecheck gamma e =
  19. match e with
  20. | Var ident -> TInt
  21. | Function(ident, fbtype, expr) -> TInt
  22. | LetRec(ident, ident1, fbtype, expr, fbtype2, expr2) -> TInt
  23. | Appl(expr1, expr2) -> TInt
  24. | Plus(expr1, expr2) -> TInt
  25. | Minus(expr1, expr2) -> TInt
  26. | Equal(expr1, expr2) -> TInt
  27. | And (expr1, expr2) -> TInt
  28. | Or (expr1, expr2) -> TInt
  29. | Not(expr) -> TInt
  30. | If(expr1, expr2, expr3) -> TInt
  31. | Int(tint) -> TInt
  32. | Bool(boo) -> TBool
  33. | Ref(expr) -> TInt
  34. | Get(expr) -> TInt
  35. | Record(reclist) -> TInt
  36. | Select(lab, expr) -> TInt
  37. | Raise(exnid, fbtype, expr) -> TInt
  38. | Try(expr, exnid, ident, fbtype, expr1) -> TInt
  39. | Cell(tint) -> TInt
  40.  
  41. let typecheck e = baby_typecheck [] e;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement