aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Lex.x
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-06-17 19:10:29 +0100
committerIan Lynagh <igloo@earth.li>2011-06-17 19:10:29 +0100
commit8739a6bd59f562bb550c915f1d2b2a327b748572 (patch)
tree6ce78264c2b2e1103209c70f3560b816f884937e /src/Haddock/Lex.x
parentab24835eadb99059934d7a14f86564eea6449257 (diff)
Fix build
Diffstat (limited to 'src/Haddock/Lex.x')
-rw-r--r--src/Haddock/Lex.x17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Haddock/Lex.x b/src/Haddock/Lex.x
index 2f0b4cd3..17267656 100644
--- a/src/Haddock/Lex.x
+++ b/src/Haddock/Lex.x
@@ -28,6 +28,7 @@ import StringBuffer
import RdrName
import SrcLoc
import DynFlags
+import FastString
import Data.Char
import Numeric
@@ -178,19 +179,25 @@ begin sc = \_ _ _ cont _ -> cont sc
ident :: Action
ident pos str sc cont dflags =
- case strToHsQNames dflags id of
+ case strToHsQNames dflags loc id of
Just names -> (TokIdent names, pos) : cont sc
Nothing -> (TokString str, pos) : cont sc
where id = init (tail str)
-
-strToHsQNames :: DynFlags -> String -> Maybe [RdrName]
-strToHsQNames dflags str0 =
+ -- TODO: Get the real filename here. Maybe we should just be
+ -- using GHC SrcLoc's ourself?
+ filename = mkFastString "<unknown file>"
+ loc = case pos of
+ AlexPn _ line col ->
+ mkRealSrcLoc filename line col
+
+strToHsQNames :: DynFlags -> RealSrcLoc -> String -> Maybe [RdrName]
+strToHsQNames dflags loc str0 =
#if MIN_VERSION_ghc(7,1,0)
let buffer = stringToStringBuffer str0
#else
let buffer = unsafePerformIO (stringToStringBuffer str0)
#endif
- pstate = mkPState dflags buffer noSrcLoc
+ pstate = mkPState dflags buffer loc
result = unP parseIdentifier pstate
in case result of
POk _ name -> Just [unLoc name]