summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Grammar
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-06-26 14:46:18 +0000
committerhallgren <hallgren@chalmers.se>2012-06-26 14:46:18 +0000
commitb094274c0e6e0218977a65821066a3970254810a (patch)
treee5cdbb20a5fb276aec6e081802c163fcb213ad91 /src/compiler/GF/Grammar
parenta38efe70c6aa340242cb25c3b8fd2845f98b1bb8 (diff)
Report many type errors instead of stopping after the first one
In GF.Compile.CheckGrammar, use a new topological sorting function that groups independent judgements, allowing them all to be checked before continuing or reporting errors.
Diffstat (limited to 'src/compiler/GF/Grammar')
-rw-r--r--src/compiler/GF/Grammar/Macros.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/compiler/GF/Grammar/Macros.hs b/src/compiler/GF/Grammar/Macros.hs
index e8842375d..bf7e7047b 100644
--- a/src/compiler/GF/Grammar/Macros.hs
+++ b/src/compiler/GF/Grammar/Macros.hs
@@ -568,10 +568,20 @@ allDependencies ism b =
topoSortJments :: SourceModule -> Err [(Ident,Info)]
topoSortJments (m,mi) = do
is <- either
- return
+ return
(\cyc -> Bad (render (text "circular definitions:" <+> fsep (map ppIdent (head cyc)))))
(topoTest (allDependencies (==m) (jments mi)))
return (reverse [(i,info) | i <- is, Ok info <- [lookupTree showIdent i (jments mi)]])
+
+topoSortJments2 :: SourceModule -> Err [[(Ident,Info)]]
+topoSortJments2 (m,mi) = do
+ iss <- either
+ return
+ (\cyc -> fail (render (text "circular definitions:"
+ <+> fsep (map ppIdent (head cyc)))))
+ (topoTest2 (allDependencies (==m) (jments mi)))
+ return
+ [[(i,info) | i<-is,Ok info<-[lookupTree showIdent i (jments mi)]] | is<-iss]
{-
-- | Smart constructor for PSeq
pSeq p1 p2 =