"{-#" $whitechar* (INCLUDE|include) { lex_string_prag ITinclude_prag }
}
+<0,option_prags,glaexts> {
+ -- This is to catch things like {-# OPTIONS OPTIONS_HUGS ...
+ "{-#" $whitechar* $idchar+ { nested_comment }
+}
+
-- '0' state: ordinary lexemes
-- 'glaexts' state: glasgow extensions (postfix '#', etc.)
,("→", ITrarrow, bit glaExtsBit)
,("←", ITlarrow, bit glaExtsBit)
,("⋯", ITdotdot, bit glaExtsBit)
+ -- ToDo: ideally, → and ∷ should be "specials", so that they cannot
+ -- form part of a large operator. This would let us have a better
+ -- syntax for kinds: ɑ∷*→* would be a legal kind signature. (maybe).
#endif
]
alexGetChar (AI loc ofs s)
| atEnd s = Nothing
| otherwise = adj_c `seq` loc' `seq` ofs' `seq` s' `seq`
+ --trace (show (ord c)) $
Just (adj_c, (AI loc' ofs' s'))
where (c,s') = nextChar s
loc' = advanceSrcLoc loc c
alexGetChar' (AI loc ofs s)
| atEnd s = Nothing
| otherwise = c `seq` loc' `seq` ofs' `seq` s' `seq`
+ --trace (show (ord c)) $
Just (c, (AI loc' ofs' s'))
where (c,s') = nextChar s
loc' = advanceSrcLoc loc c
span `seq` setLastToken span bytes
t span buf bytes
--- ToDo: Alex reports the buffer at the start of the erroneous lexeme,
--- but it would be more informative to report the location where the
--- error was actually discovered, especially if this is a decoding
--- error.
-reportLexError loc1 loc2 buf str =
+reportLexError loc1 loc2 buf str
+ | atEnd buf = failLocMsgP loc1 loc2 (str ++ " at end of input")
+ | otherwise =
let
c = fst (nextChar buf)
in
if c == '\0' -- decoding errors are mapped to '\0', see utf8DecodeChar#
- then failLocMsgP loc2 loc2 "UTF-8 decoding error"
+ then failLocMsgP loc2 loc2 (str ++ " (UTF-8 decoding error)")
else failLocMsgP loc1 loc2 (str ++ " at character " ++ show c)
}