Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Core.Std
- type primitive = Add | Sub | Mul | Div | Int of int
- let re_int = Str.regexp "^[-]?[0-9]+$"
- let primitive_of_string s =
- if (Str.string_match re_int s) 0 then Int (int_of_string s)
- else if s = "+" then Add
- else if s = "-" then Sub
- else if s = "*" then Mul
- else if s = "/" then Div
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement