@@ -144,12 +144,12 @@ takeToken lex str
144144 = do i <- scan lex 0 str -- i must be > 0 if successful
145145 pure (substr 0 i (getString str), strTail i str)
146146
147−||| Recognise a digit 0-9
147+||| Recognise a single digit 0-9
148148export
149149digit : Lexer
150150digit = pred isDigit
151151
152−||| Recognise one or more digits 0-9
152+||| Recognise one or more digits
153153export
154154digits : Lexer
155155digits = some digit
@@ -162,7 +162,17 @@ exact str with (unpack str)
162162 exact str | (x :: xs)
163163 = foldl SeqEmpty (is x) (map is xs)
164164
165−||| Recognise an alpha character
165+||| Recognise a single hexidecimal digit
166+export
167+hexDigit : Lexer
168+hexDigit = digit <|> oneOf "abcdefABCDEF"
169+
170+||| Recognise one or more hexidecimal digits
171+export
172+hexDigits : Lexer
173+hexDigits = some hexDigit
174+
175+||| Recognise a single alpha character
166176export
167177alpha : Lexer
168178alpha = pred isAlpha
@@ -247,6 +257,11 @@ export
247257intLit : Lexer
248258intLit = opt (is '-') <+> digits
249259
260+||| Recognise a hexidecimal literal, prefixed by "0x" or "0X"
261+export
262+hexLit : Lexer
263+hexLit = is '0' <+> oneOf "xX" <+> hexDigits
264+
250265||| A mapping from lexers to the tokens they produce.
251266||| This is a list of pairs `(Lexer, String -> tokenType)`
252267||| For each Lexer in the list, if a substring in the input matches, run