) where
-IMPORT_1_3(Char(isDigit, isAlpha, isAlphanum, isUpper))
+IMPORT_1_3(Char(isDigit, isAlpha, isAlphanum, isUpper,isLower, isSpace, ord))
IMPORT_DELOOPER(Ubiq)
IMPORT_DELOOPER(IdLoop) -- get the CostCentre type&constructors from here
import Demand ( Demand(..) {- instance Read -} )
import UniqFM ( UniqFM, listToUFM, lookupUFM)
--import FiniteMap ( FiniteMap, listToFM, lookupFM )
+#if __GLASGOW_HASKELL__ >= 202
+import Maybes ( MaybeErr(..) )
+#else
import Maybes ( Maybe(..), MaybeErr(..) )
+#endif
import Pretty
-import CharSeq ( CSeq )
import FastString
import StringBuffer
+#if __GLASGOW_HASKELL__ <= 201
import PreludeGlaST
-
+#else
+import GlaExts
+#endif
\end{code}
%************************************************************************
lex_demand (stepOnUntil (not . isSpace)
(stepOnBy# buf 3#)) -- past _S_
's'# -> case prefixMatch (stepOnBy# buf 2#) "cc_" of
- Just buf' -> lex_scc (stepOnUntil (not . isSpace)
- (stepOverLexeme buf'))
+ Just buf' -> lex_scc (stepOnUntil (not . isSpace) (stepOverLexeme buf'))
Nothing -> lex_keyword (stepOnBy# buf 1#) -- drop the '_' and assume
-- it is a keyword.
_ -> lex_keyword (stepOn buf)
Just buf' ->
case untilChar# (stepOverLexeme buf') '\"'# of
buf'' -> ITscc (mkAllCafsCC ({-module-}lexemeToFastString buf'') _NIL_):
- lexIface (stepOverLexeme buf'')
+ lexIface (stepOn (stepOverLexeme buf''))
Nothing ->
case prefixMatch (stepOn buf) "DICTs_in_...\"" of
Just buf' -> ITscc (preludeDictsCostCentre True) : lexIface (stepOverLexeme buf')
Just buf' ->
case untilChar# (stepOverLexeme buf') '\"'# of
buf'' -> ITscc (mkAllDictsCC (lexemeToFastString buf'') _NIL_ True):
- lexIface (stepOverLexeme buf'')
+ lexIface (stepOn (stepOverLexeme buf''))
Nothing ->
case prefixMatch (stepOn buf) "CAF:" of
Just buf' ->
case untilChar# (stepOverLexeme buf') '\"'# of
buf'' -> ITscc (cafifyCC (mkUserCC (lexemeToFastString buf'') _NIL_ _NIL_)):
- lexIface (stepOverLexeme buf'')
+ lexIface (stepOn (stepOverLexeme buf''))
Nothing ->
case untilChar# (stepOn buf) '\"'# of
buf' -> ITscc (mkUserCC (lexemeToFastString buf') _NIL_ _NIL_):
- lexIface (stepOverLexeme buf')
+ lexIface (stepOn (stepOverLexeme buf'))
c -> ITunknown [C# c] : lexIface (stepOn buf)
is_sym c#=
case c# of {
- ':'# -> True; '_'# -> True; '\''# -> True; '!'# -> True;
- '#'# -> True; '$'# -> True; ':'# -> True; '%'# -> True;
- '&'# -> True; '*'# -> True; '+'# -> True; '.'# -> True;
- '/'# -> True; '<'# -> True; '='# -> True; '>'# -> True;
- '?'# -> True; '\\'# -> True; '^'# -> True; '|'# -> True;
- '-'# -> True; '~'# -> True; '@'# -> True; _ -> False }
+ ':'# -> True; '_'# -> True; '\''# -> True; '!'# -> True;
+ '#'# -> True; '$'# -> True; ':'# -> True; '%'# -> True;
+ '&'# -> True; '*'# -> True; '+'# -> True; '.'# -> True;
+ '/'# -> True; '<'# -> True; '='# -> True; '>'# -> True;
+ '?'# -> True; '\\'# -> True; '^'# -> True; '|'# -> True;
+ '-'# -> True; '~'# -> True; '@'# -> True; _ -> False }
--isAlphanum c || c `elem` ":_'!#$%&*+./<=>?@\\^|-~" -- ToDo: add ISOgraphic
map (\ (x,y) -> (_PK_ x,y))
[("/\\_", ITbiglam)
,("@_", ITatsign)
+ ,("letrec_", ITletrec)
,("interface_", ITinterface)
,("usages_", ITusages)
,("versions_", ITversions)
,("of", ITof)
,("in", ITin)
,("let", ITlet)
- ,("letrec", ITletrec)
,("deriving", ITderiving)
,("->", ITrarrow)
else
doDiscard inStr (incLexeme buf)
'"'# ->
+ let
+ odd_slashes buf flg i# =
+ case lookAhead# buf i# of
+ '\\'# -> odd_slashes buf (not flg) (i# -# 1#)
+ _ -> flg
+ in
case lookAhead# buf (negateInt# 1#) of --backwards, actually
- '\\'# -> -- false alarm, escaped.
- doDiscard inStr (incLexeme buf)
+ '\\'# -> -- escaping something..
+ if odd_slashes buf True (negateInt# 2#) then
+ -- odd number of slashes, " is escaped.
+ doDiscard inStr (incLexeme buf)
+ else
+ -- even number of slashes, \ is escaped.
+ doDiscard (not inStr) (incLexeme buf)
_ -> case inStr of -- forced to avoid build-up
True -> doDiscard False (incLexeme buf)
False -> doDiscard True (incLexeme buf)
-----------------------------------------------------------------
ifaceParseErr ln toks sty
- = ppCat [ppPStr SLIT("Interface-file parse error: line"), ppInt ln, ppPStr SLIT("toks="), ppStr (show (take 10 toks))]
+ = hsep [ptext SLIT("Interface-file parse error: line"), int ln, ptext SLIT("toks="), text (show (take 10 toks))]
\end{code}