Skip to content

Instantly share code, notes, and snippets.

@nishio
Created July 15, 2010 08:20
Show Gist options
  • Save nishio/476656 to your computer and use it in GitHub Desktop.
Save nishio/476656 to your computer and use it in GitHub Desktop.
let rec tokenize (data : char list) : token list =
match data with
'['::xs -> Begin::(tokenize xs)
| ']'::xs -> End::(tokenize xs)
| '+'::xs -> (Inc 1)::(tokenize xs)
| '-'::xs -> (Dec 1)::(tokenize xs)
| '>'::xs -> (Right 1)::(tokenize xs)
| '<'::xs -> (Left 1)::(tokenize xs)
| '.'::xs -> Print::(tokenize xs)
| ','::xs -> Read::(tokenize xs)
| _::xs -> (tokenize xs)
| [] -> []
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment