Created
January 8, 2016 01:38
-
-
Save yminsky/0eaa35d3f258fbdbd4b9 to your computer and use it in GitHub Desktop.
yet better formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec lexwhile prop inp = | |
match inp with | |
| c::cs when prop c -> | |
let (tok,rest) = lexwhile prop cs in | |
(c^tok,rest) | |
| _ -> ("",inp) | |
;; | |
let rec lex inp = | |
match snd (lexwhile space inp) with | |
| [] -> [] | |
| c::cs -> | |
let prop = | |
if alphanumeric(c) then alphanumeric | |
else if symbolic(c) then symbolic | |
else (fun c -> false) | |
in | |
let (toktl,rest) = lexwhile prop cs in | |
(c^toktl) :: lex rest | |
;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment