Created
April 26, 2015 14:14
-
-
Save SteveGilham/fbe5ca8d532dd7ac7e1b to your computer and use it in GitHub Desktop.
Continuation based lexer (partial)
This file contains hidden or 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
type LispLex = Bra | Ket | Dot | Str of string | Num of int | Symbol of string | |
let alpha c = ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) | |
let digit c = (c >= '0') && (c <= '9') | |
let eqChar c c' = c = c' | |
let l2s l = String(List.toArray l) | |
let ( ^| ) p q = fun x -> (p x) || (q x) | |
// Read a symbol from the input | |
let readSymbol s char g = | |
(lexGetChar s, alpha ^| digit ^| eqChar '_') ^* | |
(fun l -> | |
fun opt -> | |
lexPutLexeme s (Symbol (l2s ([char]@l))) (g opt));; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment