Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Forked from micahrj/gist:350967
Created October 31, 2015 20:17
Show Gist options
  • Save Teino1978-Corp/9dd294eb78a0e9a588e8 to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/9dd294eb78a0e9a588e8 to your computer and use it in GitHub Desktop.
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