-
-
Save Teino1978-Corp/9dd294eb78a0e9a588e8 to your computer and use it in GitHub Desktop.
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
tokenBase = token showTok posFromTok | |
where showTok (p, t) = show t | |
posFromTok (p, t) = p | |
match x = tokenBase testTok | |
where testTok (p, t) = if t == x then Just t else Nothing | |
advance = tokenBase testTok | |
where testTok (p, t) = Just t | |
-- | |
data Token = NameTok String | |
| KeywordTok String | |
| StringTok String | |
| NumberTok Double | |
| OperTok String | |
| DelimTok Char deriving (Eq) | |
instance Show Token where | |
show t = case t of | |
NameTok n -> n | |
KeywordTok k -> k | |
StringTok s -> "\"" ++ s ++ "\"" | |
NumberTok n -> show n | |
OperTok o -> o | |
DelimTok d -> [d] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment