mtl >=2.2 && <3,
parsers >=0.12 && <1,
text >=1.2 && <2,
- trifecta >=1.5 && <2,
+ trifecta >=1.6 && <1.7,
ansi-wl-pprint >= 0.6 && <1,
wl-pprint-extras >=3.5 && <4
cmdlib >= 0.3 && <1,
directory >= 1.2 && <2,
filepath >= 1.4 && <2,
- trifecta >=1.5 && <2,
+ trifecta >=1.6 && <1.7,
ansi-wl-pprint >= 0.6 && <1,
wl-pprint-extras >=3.5 && <4,
grade >=0.1
withDefines sectys defi act = do
mdefines <- T.parseFromFileEx (parseDefns sectys) defi
case mdefines of
- T.Failure f -> parseErr f
+ T.Failure f -> parseErr (T._errDoc f)
T.Success defs -> Right <$> act defs
where
parseErr f = pure $ Left ( "Error while parsing defines" TPP.<+> TPP.pretty defi TPP.<> ":"
import qualified Text.Trifecta as T
import qualified Text.Trifecta.Delta as T
import qualified Text.Parser.LookAhead as T
--- import qualified Text.PrettyPrint.ANSI.Leijen as PP
+import qualified Text.PrettyPrint.ANSI.Leijen as PP
import Grade.Types
import Grade.ParseUtils
(dcs, reuse) <- T.try ((,) <$> many (hashComment) <*> leadchar)
dn T.:^ c <- T.careted (DN <$> word)
(dm, ds) <- dl
+ -- XXX optional comment here?
dt <- untilDotLine
pure (dn, ds, DingDefn (DingMeta dm dt) c reuse dcs)
where
(dn, ds, db) <- parseDingDefn fsdt
case M.lookup dn m of
Nothing -> go (s `mappend` ds) (M.insert dn db m) ((dn,db):l)
- Just _ -> do
- T.raiseErr (T.Err (Just "Duplicate ding definition") [] mempty)
+ Just d -> do
+ -- XXX this causes an error to be printed out *after* the ding,
+ -- typically at the beginning of the next line. Argh. It's also
+ -- really ugly but more informative than it was.
+ T.raiseErr (T.Err (Just $ "Duplicate ding definition" PP.<+> (PP.pretty $ show $ unDN dn) PP.<+> "original at"
+ PP.<+> (PP.pretty $ show $ _dingd_loc d)) [] mempty [])
-- | Parse a definitions file
parseDefns :: (T.DeltaParsing f, T.MarkParsing T.Delta f, T.Errable f, T.LookAheadParsing f)
Nothing -> go (M.insert sn sb m) ((sn,sb):l)
Just _ -> do
T.release (T.delta $ case sb of ExSec s -> _sec_loc s)
- T.raiseErr (T.Err (Just "Duplicate section definition") [] mempty)
+ T.raiseErr (T.Err (Just "Duplicate section definition") [] mempty [])
------------------------------------------------------------------------ }}}
-- Data ---------------------------------------------------------------- {{{