diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2011-11-02 11:44:59 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2011-11-02 11:44:59 +0000 |
| commit | 5fe49ed9f7ac7089301e867e55bfedefcba230dd (patch) | |
| tree | 3d49a4fbd3e3af5350b4e276d65ec3c17f0907c3 /src/compiler/GF/Compile/CheckGrammar.hs | |
| parent | 42af63414fae6cec2ea6d648464f9475501b2b28 (diff) | |
Now the compiler maintains more precise information for the source locations of the different definitions. There is a --tags option which generates a list of all identifiers with their source locations.
Diffstat (limited to 'src/compiler/GF/Compile/CheckGrammar.hs')
| -rw-r--r-- | src/compiler/GF/Compile/CheckGrammar.hs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/compiler/GF/Compile/CheckGrammar.hs b/src/compiler/GF/Compile/CheckGrammar.hs index b3129128b..44e2e552b 100644 --- a/src/compiler/GF/Compile/CheckGrammar.hs +++ b/src/compiler/GF/Compile/CheckGrammar.hs @@ -112,14 +112,14 @@ checkCompleteGrammar gr (am,abs) (cm,cnc) = do return $ updateTree (c,CncFun ty (Just def) pn) js Ok (CncFun ty Nothing pn) -> case mb_def of - Ok def -> return $ updateTree (c,CncFun ty (Just (L (0,0) def)) pn) js + Ok def -> return $ updateTree (c,CncFun ty (Just (L NoLoc def)) pn) js Bad _ -> do checkWarn $ text "no linearization of" <+> ppIdent c return js _ -> do case mb_def of Ok def -> do (cont,val) <- linTypeOfType gr cm ty let linty = (snd (valCat ty),cont,val) - return $ updateTree (c,CncFun (Just linty) (Just (L (0,0) def)) Nothing) js + return $ updateTree (c,CncFun (Just linty) (Just (L NoLoc def)) Nothing) js Bad _ -> do checkWarn $ text "no linearization of" <+> ppIdent c return js AbsCat (Just _) -> case lookupIdent c js of @@ -128,11 +128,11 @@ checkCompleteGrammar gr (am,abs) (cm,cnc) = do Ok (CncCat _ mt mp) -> do checkWarn $ text "no linearization type for" <+> ppIdent c <> text ", inserting default {s : Str}" - return $ updateTree (c,CncCat (Just (L (0,0) defLinType)) mt mp) js + return $ updateTree (c,CncCat (Just (L NoLoc defLinType)) mt mp) js _ -> do checkWarn $ text "no linearization type for" <+> ppIdent c <> text ", inserting default {s : Str}" - return $ updateTree (c,CncCat (Just (L (0,0) defLinType)) Nothing Nothing) js + return $ updateTree (c,CncCat (Just (L NoLoc defLinType)) Nothing Nothing) js _ -> return js checkCnc js i@(c,info) = @@ -158,15 +158,15 @@ checkInfo ms (m,mo) c info = do checkReservedId c case info of AbsCat (Just (L loc cont)) -> - mkCheck loc "category" $ + mkCheck loc "the category" $ checkContext gr cont AbsFun (Just (L loc typ0)) ma md moper -> do typ <- compAbsTyp [] typ0 -- to calculate let definitions - mkCheck loc "type of function" $ + mkCheck loc "the type of function" $ checkTyp gr typ case md of - Just eqs -> mapM_ (\(L loc eq) -> mkCheck loc "definition of function" $ + Just eqs -> mapM_ (\(L loc eq) -> mkCheck loc "the definition of function" $ checkDef gr (m,c) typ eq) eqs Nothing -> return () return (AbsFun (Just (L loc typ)) ma md moper) @@ -204,7 +204,7 @@ checkInfo ms (m,mo) c info = do checkError (text "No definition given to the operation") return (ResOper pty' pde') - ResOverload os tysts -> chIn (0,0) "overloading" $ do + ResOverload os tysts -> chIn NoLoc "overloading" $ do tysts' <- mapM (uncurry $ flip (\(L loc1 t) (L loc2 ty) -> checkLType gr [] t ty >>= \(t,ty) -> return (L loc1 t, L loc2 ty))) tysts -- return explicit ones tysts0 <- checkErr $ lookupOverload gr (m,c) -- check against inherited ones too tysts1 <- mapM (uncurry $ flip (checkLType gr [])) @@ -215,17 +215,17 @@ checkInfo ms (m,mo) c info = do sort [let (xs,t) = typeFormCnc x in t : map (\(b,x,t) -> t) xs | (_,x) <- tysts1] return (ResOverload os [(y,x) | (x,y) <- tysts']) - ResParam (Just pcs) _ -> do - ts <- liftM concat $ mapM mkPar pcs - return (ResParam (Just pcs) (Just ts)) + ResParam (Just (L loc pcs)) _ -> do + ts <- chIn loc "parameter type" $ + liftM concat $ mapM mkPar pcs + return (ResParam (Just (L loc pcs)) (Just ts)) _ -> return info where gr = mGrammar ((m,mo) : ms) - chIn loc cat = checkIn (text "Happened in" <+> text cat <+> ppIdent c <+> ppPosition m loc <> colon) + chIn loc cat = checkIn (ppLocation (msrc mo) loc <> colon $$ text "Happened in" <+> text cat <+> ppIdent c) - mkPar (L loc (f,co)) = - chIn loc "parameter type" $ do + mkPar (f,co) = do vs <- checkErr $ liftM combinations $ mapM (\(_,_,ty) -> allParamValues gr ty) co return $ map (mkApp (QC (m,f))) vs @@ -238,7 +238,7 @@ checkInfo ms (m,mo) c info = do mkCheck loc cat ss = case ss of [] -> return info - _ -> checkError (vcat ss $$ text "in" <+> text cat <+> ppIdent c <+> ppPosition m loc) + _ -> checkError (ppLocation (msrc mo) loc <> colon $$ text "Happened in" <+> text cat <+> ppIdent c $$ nest 3 (vcat ss)) compAbsTyp g t = case t of Vr x -> maybe (checkError (text "no value given to variable" <+> ppIdent x)) return $ lookup x g |
