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
(* Original implementation by @ytomino: https://gist.github.com/ytomino/1113165 *) | |
(* Forked by @youz: https://gist.github.com/youz/99d41967e08b8dde8a9199efdb36bee0 *) | |
(* Forked again by @woodrush: https://gist.github.com/woodrush/3d85a6569ef3c85b63bfaf9211881af6 *) | |
type token = T_w | T_W | T_v | EOF;; | |
let rec scan s i = ( | |
let length = String.length s in | |
if i >= length then length, EOF else | |
match s.[i] with | |
| 'W' -> i + 1, T_W |