Created
August 29, 2017 03:02
-
-
Save mroch/41fe68f48d2bbdb245229018eeb78561 to your computer and use it in GitHub Desktop.
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 token buf = | |
match%sedlex buf with | |
| "foo" -> print_endline (Sedlexing.Utf8.lexeme buf) | |
| "bar" -> print_endline (Sedlexing.Utf8.lexeme buf) | |
| "foobar" -> print_endline (Sedlexing.Utf8.lexeme buf) | |
| eof -> print_endline "EOF" | |
| _ -> () | |
let () = | |
let lexbuf = Sedlexing.Utf8.from_string "foobar" in | |
token lexbuf |
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 __sedlex_table_1 = | |
"\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\003" | |
let __sedlex_partition_5 = | |
function | c -> if c <= 97 then (-1) else if c <= 98 then 0 else (-1) | |
let __sedlex_partition_3 = | |
function | c -> if c <= 113 then (-1) else if c <= 114 then 0 else (-1) | |
let __sedlex_partition_4 = | |
function | c -> if c <= 110 then (-1) else if c <= 111 then 0 else (-1) | |
let __sedlex_partition_2 = | |
function | c -> if c <= 96 then (-1) else if c <= 97 then 0 else (-1) | |
let __sedlex_partition_1 = | |
function | |
| c -> | |
if c <= 102 | |
then (Char.code (__sedlex_table_1.[c - (-1)])) - 1 | |
else (-1) | |
let token buf = | |
let rec __sedlex_state_0 = | |
function | |
| buf -> | |
(match __sedlex_partition_1 (Sedlexing.next buf) with | |
| 0 -> 3 | |
| 1 -> __sedlex_state_2 buf | |
| 2 -> __sedlex_state_5 buf | |
| _ -> Sedlexing.backtrack buf) | |
and __sedlex_state_2 = | |
function | |
| buf -> | |
(match __sedlex_partition_2 (Sedlexing.next buf) with | |
| 0 -> __sedlex_state_3 buf | |
| _ -> Sedlexing.backtrack buf) | |
and __sedlex_state_3 = | |
function | |
| buf -> | |
(match __sedlex_partition_3 (Sedlexing.next buf) with | |
| 0 -> 1 | |
| _ -> Sedlexing.backtrack buf) | |
and __sedlex_state_5 = | |
function | |
| buf -> | |
(match __sedlex_partition_4 (Sedlexing.next buf) with | |
| 0 -> __sedlex_state_6 buf | |
| _ -> Sedlexing.backtrack buf) | |
and __sedlex_state_6 = | |
function | |
| buf -> | |
(match __sedlex_partition_4 (Sedlexing.next buf) with | |
| 0 -> __sedlex_state_7 buf | |
| _ -> Sedlexing.backtrack buf) | |
and __sedlex_state_7 = | |
function | |
| buf -> | |
(Sedlexing.mark buf 0; | |
(match __sedlex_partition_5 (Sedlexing.next buf) with | |
| 0 -> __sedlex_state_8 buf | |
| _ -> Sedlexing.backtrack buf)) | |
and __sedlex_state_8 = | |
function | |
| buf -> | |
(match __sedlex_partition_2 (Sedlexing.next buf) with | |
| 0 -> __sedlex_state_9 buf | |
| _ -> Sedlexing.backtrack buf) | |
and __sedlex_state_9 = | |
function | |
| buf -> | |
(match __sedlex_partition_3 (Sedlexing.next buf) with | |
| 0 -> 2 | |
| _ -> Sedlexing.backtrack buf) | |
in | |
Sedlexing.start buf; | |
(match __sedlex_state_0 buf with | |
| 0 -> print_endline (Sedlexing.Utf8.lexeme buf) | |
| 1 -> print_endline (Sedlexing.Utf8.lexeme buf) | |
| 2 -> print_endline (Sedlexing.Utf8.lexeme buf) | |
| 3 -> print_endline "EOF" | |
| _ -> ()) | |
let () = let lexbuf = Sedlexing.Utf8.from_string "foobar" in token lexbuf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment