Advertisement
Guest User

Untitled

a guest
Aug 11th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.56 KB | None | 0 0
  1.  
  2. type literal =
  3.     | Integer of int
  4.     | Float of float
  5.  
  6. type ('a, 'b) expr =
  7.     | Base of 'a
  8.     | Paren of 'b
  9.     | Neg of 'b
  10.     | Mult of 'b * 'b
  11.     ...
  12.     | Lit of literal
  13.  
  14. type types = Tint | Tfloat
  15.  
  16. type ('a, 'b) top =
  17.     (* def type name exprs *)
  18.     | Func of types * string * ('a, 'b) expr
  19.  
  20.  
  21. (* This definition is magical.
  22.  * What it allows us to do is pair any amount of information with our AST,
  23.  * without too much fiddling. Such as type data, or w/e else we might want.
  24.  *)
  25. type ('a, 'b) ast = Ast of 'a * ('b, ('a, 'b) ast) top
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement