@@ -14,7 +14,7 @@ Maintainer : The Idris Community.
15module Idris.Parser(IdrisParser(..), ImportInfo(..), addReplSyntax, clearParserWarnings,
15module Idris.Parser(IdrisParser(..), ImportInfo(..), addReplSyntax, clearParserWarnings,
16 decl, fixColour, loadFromIFile, loadModule, name, opChars, parseElabShellStep, parseConst, parseExpr, parseImports, parseTactic,
16 decl, fixColour, loadFromIFile, loadModule, name, opChars, parseElabShellStep, parseConst, parseExpr, parseImports, parseTactic,
17− runparser) where
17+ runparser, ParseError, parseErrorDoc) where
19import Idris.AbsSyntax hiding (namespace, params)
19import Idris.AbsSyntax hiding (namespace, params)
20import Idris.Core.Evaluate
20import Idris.Core.Evaluate
@@ -36,7 +36,7 @@ import Idris.Parser.Ops
36import Idris.Termination
36import Idris.Termination
37import Idris.Unlit
37import Idris.Unlit
39−import qualified Util.Pretty as P
39+import qualified Util.Pretty
40import Util.System (readSource)
40import Util.System (readSource)
42import Prelude hiding (pi)
42import Prelude hiding (pi)
@@ -57,11 +57,10 @@ import Data.Ord
57import qualified Data.Text as T
57import qualified Data.Text as T
58import qualified System.Directory as Dir (makeAbsolute)
58import qualified System.Directory as Dir (makeAbsolute)
59import System.FilePath
59import System.FilePath
60−import Text.PrettyPrint.ANSI.Leijen (Doc, plain)
61−import qualified Text.PrettyPrint.ANSI.Leijen as ANSI
60+import qualified Text.PrettyPrint.ANSI.Leijen as PP
62−import Text.Trifecta hiding (Err, char, charLiteral, natural, span, string,
61+import Text.Trifecta ((<?>))
63− stringLiteral, symbol, whiteSpace)
62+import qualified Text.Trifecta as P
64−import Text.Trifecta.Delta
63+import qualified Text.Trifecta.Delta as P
@@ -84,17 +83,17 @@ import Text.Trifecta.Delta
86moduleHeader :: IdrisParser (Maybe (Docstring ()), [String], [(FC, OutputAnnotation)])
85moduleHeader :: IdrisParser (Maybe (Docstring ()), [String], [(FC, OutputAnnotation)])
87−moduleHeader = try (do docs <- optional docComment
86+moduleHeader = P.try (do docs <- optional docComment
88− noArgs docs
87+ noArgs docs
89− reservedHL "module"
88+ reservedHL "module"
90− (i, ifc) <- identifier
89+ (i, ifc) <- identifier
91− option ';' (lchar ';')
90+ P.option ';' (lchar ';')
92− let modName = moduleName i
91+ let modName = moduleName i
93− return (fmap fst docs,
92+ return (fmap fst docs,
95− [(ifc, AnnNamespace (map T.pack modName) Nothing)]))
94+ [(ifc, AnnNamespace (map T.pack modName) Nothing)]))
96− <|> try (do lchar '%'; reserved "unqualified"
95+ <|> P.try (do lchar '%'; reserved "unqualified"
97− return (Nothing, [], []))
96+ return (Nothing, [], []))
98 <|> return (Nothing, moduleName "Main", [])
97 <|> return (Nothing, moduleName "Main", [])
99 where moduleName x = case span (/='.') x of
98 where moduleName x = case span (/='.') x of
100 (x, "") -> [x]
99 (x, "") -> [x]
@@ -119,12 +118,11 @@ data ImportInfo = ImportInfo { import_reexport :: Bool
119import_ :: IdrisParser ImportInfo
118import_ :: IdrisParser ImportInfo
120import_ = do fc <- getFC
119import_ = do fc <- getFC
121 reservedHL "import"
120 reservedHL "import"
122− reexport <- option False (do reservedHL "public"
121+ reexport <- P.option False (True <$ reservedHL "public")
124 (id, idfc) <- identifier
122 (id, idfc) <- identifier
125 newName <- optional (do reservedHL "as"
123 newName <- optional (do reservedHL "as"
126 identifier)
124 identifier)
127− option ';' (lchar ';')
125+ P.option ';' (lchar ';')
128 return $ ImportInfo reexport (toPath id)
126 return $ ImportInfo reexport (toPath id)
129 (fmap (\(n, fc) -> (toPath n, fc)) newName)
127 (fmap (\(n, fc) -> (toPath n, fc)) newName)
130 (map T.pack $ ns id) fc idfc
128 (map T.pack $ ns id) fc idfc
@@ -143,7 +141,7 @@ prog syn = do whiteSpace
143 decls <- many (decl syn)
141 decls <- many (decl syn)
144 let c = concat decls
142 let c = concat decls
145 case maxline syn of
143 case maxline syn of
146− Nothing -> do notOpenBraces; eof
144+ Nothing -> do notOpenBraces; P.eof
147 _ -> return ()
145 _ -> return ()
148 ist <- get
146 ist <- get
149 fc <- getFC
147 fc <- getFC
@@ -172,7 +170,7 @@ Decl ::=
174decl :: SyntaxInfo -> IdrisParser [PDecl]
172decl :: SyntaxInfo -> IdrisParser [PDecl]
175−decl syn = try (externalDecl syn)
173+decl syn = P.try (externalDecl syn)
176 <|> internalDecl syn
174 <|> internalDecl syn
177 <?> "declaration"
175 <?> "declaration"
@@ -195,13 +193,13 @@ internalDecl syn
195 if continue then
193 if continue then
196 do notEndBlock
194 do notEndBlock
197 declBody continue
195 declBody continue
198− else try (do notEndBlock
196+ else P.try (do notEndBlock
199− declBody continue)
197+ declBody continue)
200 <|> fail "End of readable input"
198 <|> fail "End of readable input"
201 where declBody :: Bool -> IdrisParser [PDecl]
199 where declBody :: Bool -> IdrisParser [PDecl]
202 declBody b =
200 declBody b =
203− try (implementation True syn)
201+ P.try (implementation True syn)
204− <|> try (openInterface syn)
202+ <|> P.try (openInterface syn)
205 <|> declBody' b
203 <|> declBody' b
206 <|> using_ syn
204 <|> using_ syn
207 <|> params syn
205 <|> params syn
@@ -276,9 +274,9 @@ declExtensions syn rules = declExtension syn [] (filter isDeclRule rules)
276declExtension :: SyntaxInfo -> [Maybe (Name, SynMatch)] -> [Syntax]
274declExtension :: SyntaxInfo -> [Maybe (Name, SynMatch)] -> [Syntax]
277 -> IdrisParser [PDecl]
275 -> IdrisParser [PDecl]
278declExtension syn ns rules =
276declExtension syn ns rules =
279− choice $ flip map (groupBy (ruleGroup `on` syntaxSymbols) rules) $ \rs ->
277+ P.choice $ flip map (groupBy (ruleGroup `on` syntaxSymbols) rules) $ \rs ->
280 case head rs of -- can never be []
278 case head rs of -- can never be []
281− DeclRule (symb:_) _ -> try $ do
279+ DeclRule (symb:_) _ -> P.try $ do
282 n <- extSymbol symb
280 n <- extSymbol symb
283 declExtension syn (n : ns) [DeclRule ss t | (DeclRule (_:ss) t) <- rs]
281 declExtension syn (n : ns) [DeclRule ss t | (DeclRule (_:ss) t) <- rs]
284 -- If we have more than one Rule in this bucket, our grammar is
282 -- If we have more than one Rule in this bucket, our grammar is
@@ -427,28 +425,28 @@ SyntaxSym ::= '[' Name_t ']'
428syntaxRule :: SyntaxInfo -> IdrisParser Syntax
426syntaxRule :: SyntaxInfo -> IdrisParser Syntax
429syntaxRule syn
427syntaxRule syn
430− = do sty <- try (do
428+ = do sty <- P.try (do
431 pushIndent
429 pushIndent
432− sty <- option AnySyntax
430+ sty <- P.option AnySyntax
433− (do reservedHL "term"; return TermSyntax
431+ (TermSyntax <$ reservedHL "term"
434− <|> do reservedHL "pattern"; return PatternSyntax)
432+ <|> PatternSyntax <$ reservedHL "pattern")
435 reservedHL "syntax"
433 reservedHL "syntax"
436 return sty)
434 return sty)
437 syms <- some syntaxSym
435 syms <- some syntaxSym
438− when (all isExpr syms) $ unexpected "missing keywords in syntax rule"
436+ when (all isExpr syms) $ P.unexpected "missing keywords in syntax rule"
439 let ns = mapMaybe getName syms
437 let ns = mapMaybe getName syms
440 when (length ns /= length (nub ns))
438 when (length ns /= length (nub ns))
441− $ unexpected "repeated variable in syntax rule"
439+ $ P.unexpected "repeated variable in syntax rule"
442 lchar '='
440 lchar '='
443 tm <- typeExpr (allowImp syn) >>= uniquifyBinders [n | Binding n <- syms]
441 tm <- typeExpr (allowImp syn) >>= uniquifyBinders [n | Binding n <- syms]
444 terminator
442 terminator
445 return (Rule (mkSimple syms) tm sty)
443 return (Rule (mkSimple syms) tm sty)
446 <|> do reservedHL "decl"; reservedHL "syntax"
444 <|> do reservedHL "decl"; reservedHL "syntax"
447 syms <- some syntaxSym
445 syms <- some syntaxSym
448− when (all isExpr syms) $ unexpected "missing keywords in syntax rule"
446+ when (all isExpr syms) $ P.unexpected "missing keywords in syntax rule"
449 let ns = mapMaybe getName syms
447 let ns = mapMaybe getName syms
450 when (length ns /= length (nub ns))
448 when (length ns /= length (nub ns))
451− $ unexpected "repeated variable in syntax rule"
449+ $ P.unexpected "repeated variable in syntax rule"
452 lchar '='
450 lchar '='
453 openBlock
451 openBlock
454 dec <- some (decl syn)
452 dec <- some (decl syn)
@@ -544,10 +542,10 @@ SyntaxSym ::= '[' Name_t ']'
546syntaxSym :: IdrisParser SSymbol
544syntaxSym :: IdrisParser SSymbol
547−syntaxSym = try (do lchar '['; n <- fst <$> name; lchar ']'
545+syntaxSym = P.try (do lchar '['; n <- fst <$> name; lchar ']'
548− return (Expr n))
546+ return (Expr n))
549− <|> try (do lchar '{'; n <- fst <$> name; lchar '}'
547+ <|> P.try (do lchar '{'; n <- fst <$> name; lchar '}'
550− return (Binding n))
548+ return (Binding n))
551 <|> do n <- fst <$> iName []
549 <|> do n <- fst <$> iName []
552 return (Keyword n)
550 return (Keyword n)
553 <|> do sym <- fmap fst stringLiteral
551 <|> do sym <- fmap fst stringLiteral
@@ -561,11 +559,11 @@ syntaxSym = try (do lchar '['; n <- fst <$> name; lchar ']'
563fnDecl :: SyntaxInfo -> IdrisParser [PDecl]
561fnDecl :: SyntaxInfo -> IdrisParser [PDecl]
564−fnDecl syn = try (do notEndBlock
562+fnDecl syn = P.try (do notEndBlock
565− d <- fnDecl' syn
563+ d <- fnDecl' syn
566− i <- get
564+ i <- get
567− let d' = fmap (desugar syn i) d
565+ let d' = fmap (desugar syn i) d
568− return [d']) <?> "function declaration"
566+ return [d']) <?> "function declaration"
570{-| Parses a function declaration
568{-| Parses a function declaration
@@ -580,7 +578,7 @@ fnDecl syn = try (do notEndBlock
581fnDecl' :: SyntaxInfo -> IdrisParser PDecl
579fnDecl' :: SyntaxInfo -> IdrisParser PDecl
582fnDecl' syn = checkDeclFixity $
580fnDecl' syn = checkDeclFixity $
583− do (doc, argDocs, fc, opts', n, nfc, acc) <- try (do
581+ do (doc, argDocs, fc, opts', n, nfc, acc) <- P.try (do
584 pushIndent
582 pushIndent
585 (doc, argDocs) <- docstring syn
583 (doc, argDocs) <- docstring syn
586 (opts, acc) <- fnOpts
584 (opts, acc) <- fnOpts
@@ -658,41 +656,32 @@ NameTimesList ::=
659fnOpt :: IdrisParser FnOpt
657fnOpt :: IdrisParser FnOpt
660fnOpt = do reservedHL "total"; return TotalFn
658fnOpt = do reservedHL "total"; return TotalFn
661− <|> do reservedHL "partial"; return PartialFn
659+ <|> PartialFn <$ reservedHL "partial"
662− <|> do reservedHL "covering"; return CoveringFn
660+ <|> CoveringFn <$ reservedHL "covering"
663− <|> do try (lchar '%' *> reserved "export"); c <- fmap fst stringLiteral;
661+ <|> do P.try (lchar '%' *> reserved "export"); c <- fmap fst stringLiteral;
664− return $ CExport c
662+ return $ CExport c
665− <|> do try (lchar '%' *> reserved "no_implicit");
663+ <|> NoImplicit <$ P.try (lchar '%' *> reserved "no_implicit")
667− <|> do try (lchar '%' *> reserved "inline");
664+ <|> Inlinable <$ P.try (lchar '%' *> reserved "inline")
668− return Inlinable
665+ <|> StaticFn <$ P.try (lchar '%' *> reserved "static")
669− <|> do try (lchar '%' *> reserved "static");
671− <|> do try (lchar '%' *> reserved "assert_total");
666+ <|> do P.try (lchar '%' *> reserved "assert_total");
672 fc <- getFC
667 fc <- getFC
673 parserWarning fc Nothing (Msg "%assert_total is deprecated. Use the 'assert_total' function instead.")
668 parserWarning fc Nothing (Msg "%assert_total is deprecated. Use the 'assert_total' function instead.")
674 return AssertTotal
669 return AssertTotal
675− <|> do try (lchar '%' *> reserved "error_handler");
670+ <|> ErrorHandler <$ P.try (lchar '%' *> reserved "error_handler")
677− <|> do try (lchar '%' *> reserved "error_reverse");
671+ <|> ErrorReverse <$ P.try (lchar '%' *> reserved "error_reverse")
679− <|> do try (lchar '%' *> reserved "error_reduce");
672+ <|> ErrorReduce <$ P.try (lchar '%' *> reserved "error_reduce")
681− <|> do try (lchar '%' *> reserved "reflection");
683− <|> do try (lchar '%' *> reserved "hint");
673+ <|> Reflection <$ P.try (lchar '%' *> reserved "reflection")
685− <|> do try (lchar '%' *> reserved "overlapping");
674+ <|> AutoHint <$ P.try (lchar '%' *> reserved "hint")
686− return OverlappingDictionary
675+ <|> OverlappingDictionary <$ P.try (lchar '%' *> reserved "overlapping")
687 <|> do lchar '%'; reserved "specialise";
676 <|> do lchar '%'; reserved "specialise";
688− lchar '['; ns <- sepBy nameTimes (lchar ','); lchar ']';
677+ lchar '['; ns <- P.sepBy nameTimes (lchar ','); lchar ']';
689 return $ Specialise ns
678 return $ Specialise ns
690− <|> do reservedHL "implicit"; return Implicit
679+ <|> Implicit <$ reservedHL "implicit"
691 <?> "function modifier"
680 <?> "function modifier"
692 where nameTimes :: IdrisParser (Name, Maybe Int)
681 where nameTimes :: IdrisParser (Name, Maybe Int)
693 nameTimes = do n <- fst <$> fnName
682 nameTimes = do n <- fst <$> fnName
694− t <- option Nothing (do reds <- fmap fst natural
683+ t <- P.option Nothing (do reds <- fmap fst natural
695− return (Just (fromInteger reds)))
684+ return (Just (fromInteger reds)))
696 return (n, t)
685 return (n, t)
698{-| Parses a postulate
687{-| Parses a postulate
@@ -705,10 +694,10 @@ Postulate ::=
706postulate :: SyntaxInfo -> IdrisParser PDecl
695postulate :: SyntaxInfo -> IdrisParser PDecl
707postulate syn = do (doc, ext)
696postulate syn = do (doc, ext)
708− <- try $ do (doc, _) <- docstring syn
697+ <- P.try $ do (doc, _) <- docstring syn
709− pushIndent
698+ pushIndent
710− ext <- ppostDecl
699+ ext <- ppostDecl
711− return (doc, ext)
700+ return (doc, ext)
712 ist <- get
701 ist <- get
713 (opts, acc) <- fnOpts
702 (opts, acc) <- fnOpts
714 (n_in, nfc) <- fnName
703 (n_in, nfc) <- fnName
@@ -768,7 +757,7 @@ openInterface syn =
768 do reservedHL "using"
757 do reservedHL "using"
769 reservedHL "implementation"
758 reservedHL "implementation"
770 fc <- getFC
759 fc <- getFC
771− ns <- sepBy1 fnName (lchar ',')
760+ ns <- P.sepBy1 fnName (lchar ',')
773 openBlock
762 openBlock
774 ds <- many (decl syn)
763 ds <- many (decl syn)
@@ -848,14 +837,14 @@ InterfaceBlock ::=
848interfaceBlock :: SyntaxInfo -> IdrisParser (Maybe (Name, FC), Docstring (Either Err PTerm), [PDecl])
837interfaceBlock :: SyntaxInfo -> IdrisParser (Maybe (Name, FC), Docstring (Either Err PTerm), [PDecl])
849interfaceBlock syn = do reservedHL "where"
838interfaceBlock syn = do reservedHL "where"
850 openBlock
839 openBlock
851− (cn, cd) <- option (Nothing, emptyDocstring) $
840+ (cn, cd) <- P.option (Nothing, emptyDocstring) $
852− try (do (doc, _) <- option noDocs docComment
841+ P.try (do (doc, _) <- P.option noDocs docComment
853− n <- constructor
842+ n <- constructor
854− return (Just n, doc))
843+ return (Just n, doc))
855 ist <- get
844 ist <- get
856 let cd' = annotate syn ist cd
845 let cd' = annotate syn ist cd
858− ds <- many (notEndBlock >> try (implementation True syn)
847+ ds <- many (notEndBlock >> P.try (implementation True syn)
859 <|> do x <- data_ syn
848 <|> do x <- data_ syn
860 return [x]
849 return [x]
861 <|> fnDecl syn)
850 <|> fnDecl syn)
@@ -886,24 +875,24 @@ Interface ::=
887interface_ :: SyntaxInfo -> IdrisParser [PDecl]
876interface_ :: SyntaxInfo -> IdrisParser [PDecl]
888interface_ syn = do (doc, argDocs, acc)
877interface_ syn = do (doc, argDocs, acc)
889− <- try (do (doc, argDocs) <- docstring syn
878+ <- P.try (do (doc, argDocs) <- docstring syn
890− acc <- accessibility
879+ acc <- accessibility
891− interfaceKeyword
880+ interfaceKeyword
892− return (doc, argDocs, acc))
881+ return (doc, argDocs, acc))
893 fc <- getFC
882 fc <- getFC
894 cons <- constraintList syn
883 cons <- constraintList syn
895 let cons' = [(c, ty) | (_, c, _, ty) <- cons]
884 let cons' = [(c, ty) | (_, c, _, ty) <- cons]
896 (n_in, nfc) <- fnName
885 (n_in, nfc) <- fnName
897 let n = expandNS syn n_in
886 let n = expandNS syn n_in
898 cs <- many carg
887 cs <- many carg
899− fds <- option [(cn, NoFC) | (cn, _, _) <- cs] fundeps
888+ fds <- P.option [(cn, NoFC) | (cn, _, _) <- cs] fundeps
900− (cn, cd, ds) <- option (Nothing, fst noDocs, []) (interfaceBlock syn)
889+ (cn, cd, ds) <- P.option (Nothing, fst noDocs, []) (interfaceBlock syn)
901 accData acc n (concatMap declared ds)
890 accData acc n (concatMap declared ds)
902 return [PInterface doc syn fc cons' n nfc cs argDocs fds ds cn cd]
891 return [PInterface doc syn fc cons' n nfc cs argDocs fds ds cn cd]
903 <?> "interface declaration"
892 <?> "interface declaration"
905 fundeps :: IdrisParser [(Name, FC)]
894 fundeps :: IdrisParser [(Name, FC)]
906− fundeps = do lchar '|'; sepBy name (lchar ',')
895+ fundeps = do lchar '|'; P.sepBy name (lchar ',')
908 interfaceKeyword :: IdrisParser ()
897 interfaceKeyword :: IdrisParser ()
909 interfaceKeyword = reservedHL "interface"
898 interfaceKeyword = reservedHL "interface"
@@ -964,7 +953,7 @@ implementation kwopt syn
965 implementationUsing :: IdrisParser [Name]
954 implementationUsing :: IdrisParser [Name]
966 implementationUsing = do reservedHL "using"
955 implementationUsing = do reservedHL "using"
967− ns <- sepBy1 fnName (lchar ',')
956+ ns <- P.sepBy1 fnName (lchar ',')
968 return (map fst ns)
957 return (map fst ns)
969 <|> return []
958 <|> return []
@@ -972,7 +961,7 @@ implementation kwopt syn
972docstring :: SyntaxInfo
961docstring :: SyntaxInfo
973 -> IdrisParser (Docstring (Either Err PTerm),
962 -> IdrisParser (Docstring (Either Err PTerm),
974 [(Name,Docstring (Either Err PTerm))])
963 [(Name,Docstring (Either Err PTerm))])
975−docstring syn = do (doc, argDocs) <- option noDocs docComment
964+docstring syn = do (doc, argDocs) <- P.option noDocs docComment
976 ist <- get
965 ist <- get
977 let doc' = annotCode (tryFullExpr syn ist) doc
966 let doc' = annotCode (tryFullExpr syn ist) doc
978 argDocs' = [ (n, annotCode (tryFullExpr syn ist) d)
967 argDocs' = [ (n, annotCode (tryFullExpr syn ist) d)
@@ -1005,8 +994,8 @@ NameList ::=
1006usingDeclList :: SyntaxInfo -> IdrisParser [Using]
995usingDeclList :: SyntaxInfo -> IdrisParser [Using]
1007usingDeclList syn
996usingDeclList syn
1008− = try (sepBy1 (usingDecl syn) (lchar ','))
997+ = P.try (P.sepBy1 (usingDecl syn) (lchar ','))
1009− <|> do ns <- sepBy1 (fst <$> name) (lchar ',')
998+ <|> do ns <- P.sepBy1 (fst <$> name) (lchar ',')
1010 lchar ':'
999 lchar ':'
1011 t <- typeExpr (disallowImp syn)
1000 t <- typeExpr (disallowImp syn)
1012 return (map (\x -> UImplicit x t) ns)
1001 return (map (\x -> UImplicit x t) ns)
@@ -1022,10 +1011,10 @@ UsingDecl ::=
1024usingDecl :: SyntaxInfo -> IdrisParser Using
1013usingDecl :: SyntaxInfo -> IdrisParser Using
1025−usingDecl syn = try (do x <- fst <$> fnName
1014+usingDecl syn = P.try (do x <- fst <$> fnName
1026− lchar ':'
1015+ lchar ':'
1027− t <- typeExpr (disallowImp syn)
1016+ t <- typeExpr (disallowImp syn)
1028− return (UImplicit x t))
1017+ return (UImplicit x t))
1029 <|> do c <- fst <$> fnName
1018 <|> do c <- fst <$> fnName
1030 xs <- many (fst <$> fnName)
1019 xs <- many (fst <$> fnName)
1031 return (UConstraint c xs)
1020 return (UConstraint c xs)
@@ -1068,7 +1057,7 @@ ArgExpr ::= HSimpleExpr | {- In Pattern External (User-defined) Expression -};
1069argExpr :: SyntaxInfo -> IdrisParser PTerm
1058argExpr :: SyntaxInfo -> IdrisParser PTerm
1070argExpr syn = let syn' = syn { inPattern = True } in
1059argExpr syn = let syn' = syn { inPattern = True } in
1071− try (hsimpleExpr syn') <|> simpleExternalExpr syn'
1060+ P.try (hsimpleExpr syn') <|> simpleExternalExpr syn'
1072 <?> "argument expression"
1061 <?> "argument expression"
1074{-| Parse a right hand side of a function
1063{-| Parse a right hand side of a function
@@ -1090,8 +1079,8 @@ rhs syn n = do lchar '='
1090 expr syn
1079 expr syn
1091 <|> do symbol "?=";
1080 <|> do symbol "?=";
1092 fc <- getFC
1081 fc <- getFC
1093− name <- option n' (do symbol "{"; n <- fst <$> fnName; symbol "}";
1082+ name <- P.option n' (do symbol "{"; n <- fst <$> fnName; symbol "}";
1094− return n)
1083+ return n)
1095 r <- expr syn
1084 r <- expr syn
1096 return (addLet fc name r)
1085 return (addLet fc name r)
1097 <|> impossible
1086 <|> impossible
@@ -1135,7 +1124,7 @@ WhereOrTerminator ::= WhereBlock | Terminator;
1136clause :: SyntaxInfo -> IdrisParser PClause
1125clause :: SyntaxInfo -> IdrisParser PClause
1137clause syn
1126clause syn
1138− = do wargs <- try (do pushIndent; some (wExpr syn))
1127+ = do wargs <- P.try (do pushIndent; some (wExpr syn))
1139 fc <- getFC
1128 fc <- getFC
1140 ist <- get
1129 ist <- get
1141 n <- case lastParse ist of
1130 n <- case lastParse ist of
@@ -1143,11 +1132,8 @@ clause syn
1143 Nothing -> fail "Invalid clause"
1132 Nothing -> fail "Invalid clause"
1144 (do r <- rhs syn n
1133 (do r <- rhs syn n
1145 let wsyn = syn { syn_namespace = [], syn_toplevel = False }
1134 let wsyn = syn { syn_namespace = [], syn_toplevel = False }
1146− (wheres, nmap) <- choice [do x <- whereBlock n wsyn
1135+ (wheres, nmap) <- whereBlock n wsyn <* popIndent
1149− do terminator
1136+ <|> ([], []) <$ terminator
1151 return $ PClauseR fc wargs r wheres) <|> (do
1137 return $ PClauseR fc wargs r wheres) <|> (do
1152 popIndent
1138 popIndent
1153 reservedHL "with"
1139 reservedHL "with"
@@ -1158,19 +1144,16 @@ clause syn
1158 let withs = concat ds
1144 let withs = concat ds
1159 closeBlock
1145 closeBlock
1160 return $ PWithR fc wargs wval pn withs)
1146 return $ PWithR fc wargs wval pn withs)
1161− <|> do ty <- try (do pushIndent
1147+ <|> do ty <- P.try (do pushIndent
1162− ty <- simpleExpr syn
1148+ ty <- simpleExpr syn
1163− symbol "<=="
1149+ symbol "<=="
1164− return ty)
1150+ return ty)
1165 fc <- getFC
1151 fc <- getFC
1166 n_in <- fst <$> fnName; let n = expandNS syn n_in
1152 n_in <- fst <$> fnName; let n = expandNS syn n_in
1167 r <- rhs syn n
1153 r <- rhs syn n
1168 let wsyn = syn { syn_namespace = [] }
1154 let wsyn = syn { syn_namespace = [] }
1169− (wheres, nmap) <- choice [do x <- whereBlock n wsyn
1155+ (wheres, nmap) <- whereBlock n wsyn <* popIndent
1172− do terminator
1156+ <|> ([], []) <$ terminator
1174 let capp = PLet fc RigW (sMN 0 "match") NoFC
1157 let capp = PLet fc RigW (sMN 0 "match") NoFC
1176 (PMatchApp fc n)
1159 (PMatchApp fc n)
@@ -1178,7 +1161,7 @@ clause syn
1178 ist <- get
1161 ist <- get
1179 put (ist { lastParse = Just n })
1162 put (ist { lastParse = Just n })
1180 return $ PClause fc n capp [] r wheres
1163 return $ PClause fc n capp [] r wheres
1181− <|> do (l, op, nfc) <- try (do
1164+ <|> do (l, op, nfc) <- P.try (do
1182 pushIndent
1165 pushIndent
1183 l <- argExpr syn
1166 l <- argExpr syn
1184 (op, nfc) <- symbolicOperatorFC
1167 (op, nfc) <- symbolicOperatorFC
@@ -1191,11 +1174,8 @@ clause syn
1191 wargs <- many (wExpr syn)
1174 wargs <- many (wExpr syn)
1192 (do rs <- rhs syn n
1175 (do rs <- rhs syn n
1193 let wsyn = syn { syn_namespace = [] }
1176 let wsyn = syn { syn_namespace = [] }
1194− (wheres, nmap) <- choice [do x <- whereBlock n wsyn
1177+ (wheres, nmap) <- whereBlock n wsyn <* popIndent
1197− do terminator
1178+ <|> ([], []) <$ terminator
1199 ist <- get
1179 ist <- get
1200 let capp = PApp fc (PRef nfc [nfc] n) [pexp l, pexp r]
1180 let capp = PApp fc (PRef nfc [nfc] n) [pexp l, pexp r]
1201 put (ist { lastParse = Just n })
1181 put (ist { lastParse = Just n })
@@ -1215,18 +1195,15 @@ clause syn
1215 <|> do pushIndent
1195 <|> do pushIndent
1216 (n_in, nfc) <- fnName; let n = expandNS syn n_in
1196 (n_in, nfc) <- fnName; let n = expandNS syn n_in
1217 fc <- getFC
1197 fc <- getFC
1218− args <- many (try (implicitArg (syn { inPattern = True } ))
1198+ args <- many (P.try (implicitArg (syn { inPattern = True } ))
1219− <|> try (constraintArg (syn { inPattern = True }))
1199+ <|> P.try (constraintArg (syn { inPattern = True }))
1220 <|> (fmap pexp (argExpr syn)))
1200 <|> (fmap pexp (argExpr syn)))
1221 wargs <- many (wExpr syn)
1201 wargs <- many (wExpr syn)
1222 let capp = PApp fc (PRef nfc [nfc] n) args
1202 let capp = PApp fc (PRef nfc [nfc] n) args
1223 (do r <- rhs syn n
1203 (do r <- rhs syn n
1224 let wsyn = syn { syn_namespace = [] }
1204 let wsyn = syn { syn_namespace = [] }
1225− (wheres, nmap) <- choice [do x <- whereBlock n wsyn
1205+ (wheres, nmap) <- whereBlock n wsyn <* popIndent
1228− do terminator
1206+ <|> ([], []) <$ terminator
1230 ist <- get
1207 ist <- get
1231 put (ist { lastParse = Just n })
1208 put (ist { lastParse = Just n })
1232 return $ PClause fc n capp wargs r wheres) <|> (do
1209 return $ PClause fc n capp wargs r wheres) <|> (do
@@ -1243,9 +1220,9 @@ clause syn
1243 return $ PWith fc n capp wargs wval pn withs)
1220 return $ PWith fc n capp wargs wval pn withs)
1244 <?> "function clause"
1221 <?> "function clause"
1246− optProof = option Nothing (do reservedHL "proof"
1223+ optProof = P.option Nothing (do reservedHL "proof"
1247− n <- fnName
1224+ n <- fnName
1248− return (Just n))
1225+ return (Just n))
1250 fillLHS :: Name -> PTerm -> [PTerm] -> PClause -> PClause
1227 fillLHS :: Name -> PTerm -> [PTerm] -> PClause -> PClause
1251 fillLHS n capp owargs (PClauseR fc wargs v ws)
1228 fillLHS n capp owargs (PClauseR fc wargs v ws)
@@ -1336,74 +1313,74 @@ Directive' ::= 'lib' CodeGen String_t
1338directive :: SyntaxInfo -> IdrisParser [PDecl]
1315directive :: SyntaxInfo -> IdrisParser [PDecl]
1339−directive syn = do try (lchar '%' *> reserved "lib")
1316+directive syn = do P.try (lchar '%' *> reserved "lib")
1340 cgn <- codegen_
1317 cgn <- codegen_
1341 lib <- fmap fst stringLiteral
1318 lib <- fmap fst stringLiteral
1342 return [PDirective (DLib cgn lib)]
1319 return [PDirective (DLib cgn lib)]
1343− <|> do try (lchar '%' *> reserved "link")
1320+ <|> do P.try (lchar '%' *> reserved "link")
1344 cgn <- codegen_; obj <- fst <$> stringLiteral
1321 cgn <- codegen_; obj <- fst <$> stringLiteral
1345 return [PDirective (DLink cgn obj)]
1322 return [PDirective (DLink cgn obj)]
1346− <|> do try (lchar '%' *> reserved "flag")
1323+ <|> do P.try (lchar '%' *> reserved "flag")
1347 cgn <- codegen_; flag <- fst <$> stringLiteral
1324 cgn <- codegen_; flag <- fst <$> stringLiteral
1348 return [PDirective (DFlag cgn flag)]
1325 return [PDirective (DFlag cgn flag)]
1349− <|> do try (lchar '%' *> reserved "include")
1326+ <|> do P.try (lchar '%' *> reserved "include")
1350 cgn <- codegen_
1327 cgn <- codegen_
1351 hdr <- fst <$> stringLiteral
1328 hdr <- fst <$> stringLiteral
1352 return [PDirective (DInclude cgn hdr)]
1329 return [PDirective (DInclude cgn hdr)]
1353− <|> do try (lchar '%' *> reserved "hide"); n <- fst <$> fnName
1330+ <|> do P.try (lchar '%' *> reserved "hide"); n <- fst <$> fnName
1354 return [PDirective (DHide n)]
1331 return [PDirective (DHide n)]
1355− <|> do try (lchar '%' *> reserved "freeze"); n <- fst <$> iName []
1332+ <|> do P.try (lchar '%' *> reserved "freeze"); n <- fst <$> iName []
1356 return [PDirective (DFreeze n)]
1333 return [PDirective (DFreeze n)]
1357− <|> do try (lchar '%' *> reserved "thaw"); n <- fst <$> iName []
1334+ <|> do P.try (lchar '%' *> reserved "thaw"); n <- fst <$> iName []
1358 return [PDirective (DThaw n)]
1335 return [PDirective (DThaw n)]
1359 -- injectivity assertins are intended for debugging purposes
1336 -- injectivity assertins are intended for debugging purposes
1360 -- only, and won't be documented/could be removed at any point
1337 -- only, and won't be documented/could be removed at any point
1361− <|> do try (lchar '%' *> reserved "assert_injective"); n <- fst <$> fnName
1338+ <|> do P.try (lchar '%' *> reserved "assert_injective"); n <- fst <$> fnName
1362 return [PDirective (DInjective n)]
1339 return [PDirective (DInjective n)]
1363 -- Assert totality of something after definition. This is
1340 -- Assert totality of something after definition. This is
1364 -- here as a debugging aid, so commented out...
1341 -- here as a debugging aid, so commented out...
1365−-- <|> do try (lchar '%' *> reserved "assert_set_total"); n <- fst <$> fnName
1342+-- <|> do P.try (lchar '%' *> reserved "assert_set_total"); n <- fst <$> fnName
1366-- return [PDirective (DSetTotal n)]
1343-- return [PDirective (DSetTotal n)]
1367− <|> do try (lchar '%' *> reserved "access")
1344+ <|> do P.try (lchar '%' *> reserved "access")
1368 acc <- accessibility
1345 acc <- accessibility
1369 ist <- get
1346 ist <- get
1370 put ist { default_access = acc }
1347 put ist { default_access = acc }
1371 return [PDirective (DAccess acc)]
1348 return [PDirective (DAccess acc)]
1372− <|> do try (lchar '%' *> reserved "default"); tot <- totality
1349+ <|> do P.try (lchar '%' *> reserved "default"); tot <- totality
1373 i <- get
1350 i <- get
1374 put (i { default_total = tot } )
1351 put (i { default_total = tot } )
1375 return [PDirective (DDefault tot)]
1352 return [PDirective (DDefault tot)]
1376− <|> do try (lchar '%' *> reserved "logging")
1353+ <|> do P.try (lchar '%' *> reserved "logging")
1377 i <- fst <$> natural
1354 i <- fst <$> natural
1378 return [PDirective (DLogging i)]
1355 return [PDirective (DLogging i)]
1379− <|> do try (lchar '%' *> reserved "dynamic")
1356+ <|> do P.try (lchar '%' *> reserved "dynamic")
1380− libs <- sepBy1 (fmap fst stringLiteral) (lchar ',')
1357+ libs <- P.sepBy1 (fmap fst stringLiteral) (lchar ',')
1381 return [PDirective (DDynamicLibs libs)]
1358 return [PDirective (DDynamicLibs libs)]
1382− <|> do try (lchar '%' *> reserved "name")
1359+ <|> do P.try (lchar '%' *> reserved "name")
1383 (ty, tyFC) <- fnName
1360 (ty, tyFC) <- fnName
1384− ns <- sepBy1 name (lchar ',')
1361+ ns <- P.sepBy1 name (lchar ',')
1385 return [PDirective (DNameHint ty tyFC ns)]
1362 return [PDirective (DNameHint ty tyFC ns)]
1386− <|> do try (lchar '%' *> reserved "error_handlers")
1363+ <|> do P.try (lchar '%' *> reserved "error_handlers")
1387 (fn, nfc) <- fnName
1364 (fn, nfc) <- fnName
1388 (arg, afc) <- fnName
1365 (arg, afc) <- fnName
1389− ns <- sepBy1 name (lchar ',')
1366+ ns <- P.sepBy1 name (lchar ',')
1390 return [PDirective (DErrorHandlers fn nfc arg afc ns) ]
1367 return [PDirective (DErrorHandlers fn nfc arg afc ns) ]
1391− <|> do try (lchar '%' *> reserved "language"); ext <- pLangExt;
1368+ <|> do P.try (lchar '%' *> reserved "language"); ext <- pLangExt;
1392 return [PDirective (DLanguage ext)]
1369 return [PDirective (DLanguage ext)]
1393− <|> do try (lchar '%' *> reserved "deprecate")
1370+ <|> do P.try (lchar '%' *> reserved "deprecate")
1394 n <- fst <$> fnName
1371 n <- fst <$> fnName
1395− alt <- option "" (fst <$> stringLiteral)
1372+ alt <- P.option "" (fst <$> stringLiteral)
1396 return [PDirective (DDeprecate n alt)]
1373 return [PDirective (DDeprecate n alt)]
1397− <|> do try (lchar '%' *> reserved "fragile")
1374+ <|> do P.try (lchar '%' *> reserved "fragile")
1398 n <- fst <$> fnName
1375 n <- fst <$> fnName
1399− alt <- option "" (fst <$> stringLiteral)
1376+ alt <- P.option "" (fst <$> stringLiteral)
1400 return [PDirective (DFragile n alt)]
1377 return [PDirective (DFragile n alt)]
1401 <|> do fc <- getFC
1378 <|> do fc <- getFC
1402− try (lchar '%' *> reserved "used")
1379+ P.try (lchar '%' *> reserved "used")
1403 fn <- fst <$> fnName
1380 fn <- fst <$> fnName
1404 arg <- fst <$> iName []
1381 arg <- fst <$> iName []
1405 return [PDirective (DUsed fc fn arg)]
1382 return [PDirective (DUsed fc fn arg)]
1406− <|> do try (lchar '%' *> reserved "auto_implicits")
1383+ <|> do P.try (lchar '%' *> reserved "auto_implicits")
1407 b <- on_off
1384 b <- on_off
1408 return [PDirective (DAutoImplicits b)]
1385 return [PDirective (DAutoImplicits b)]
1409 <?> "directive"
1386 <?> "directive"
@@ -1440,12 +1417,12 @@ ProviderWhat ::= 'proof' | 'term' | 'type' | 'postulate'
1442provider :: SyntaxInfo -> IdrisParser [PDecl]
1419provider :: SyntaxInfo -> IdrisParser [PDecl]
1443−provider syn = do doc <- try (do (doc, _) <- docstring syn
1420+provider syn = do doc <- P.try (do (doc, _) <- docstring syn
1444− fc1 <- getFC
1421+ fc1 <- getFC
1445− lchar '%'
1422+ lchar '%'
1446− fc2 <- reservedFC "provide"
1423+ fc2 <- reservedFC "provide"
1447− highlightP (spanFC fc1 fc2) AnnKeyword
1424+ highlightP (spanFC fc1 fc2) AnnKeyword
1448− return doc)
1425+ return doc)
1449 provideTerm doc <|> providePostulate doc
1426 provideTerm doc <|> providePostulate doc
1450 <?> "type provider"
1427 <?> "type provider"
1451 where provideTerm doc =
1428 where provideTerm doc =
@@ -1469,7 +1446,7 @@ Transform ::= '%' 'transform' Expr '==>' Expr
1471transform :: SyntaxInfo -> IdrisParser [PDecl]
1448transform :: SyntaxInfo -> IdrisParser [PDecl]
1472−transform syn = do try (lchar '%' *> reserved "transform")
1449+transform syn = do P.try (lchar '%' *> reserved "transform")
1473 -- leave it unchecked, until we work out what this should
1450 -- leave it unchecked, until we work out what this should
1474 -- actually mean...
1451 -- actually mean...
1475-- safety <- option True (do reserved "unsafe"
1452-- safety <- option True (do reserved "unsafe"
@@ -1489,10 +1466,10 @@ RunElabDecl ::= '%' 'runElab' Expr
1490runElabDecl :: SyntaxInfo -> IdrisParser PDecl
1467runElabDecl :: SyntaxInfo -> IdrisParser PDecl
1491runElabDecl syn =
1468runElabDecl syn =
1492− do kwFC <- try (do fc <- getFC
1469+ do kwFC <- P.try (do fc <- getFC
1493− lchar '%'
1470+ lchar '%'
1494− fc' <- reservedFC "runElab"
1471+ fc' <- reservedFC "runElab"
1495− return (spanFC fc fc'))
1472+ return (spanFC fc fc'))
1496 script <- expr syn <?> "elaborator script"
1473 script <- expr syn <?> "elaborator script"
1497 highlightP kwFC AnnKeyword
1474 highlightP kwFC AnnKeyword
1498 return $ PRunElabDecl kwFC script (syn_namespace syn)
1475 return $ PRunElabDecl kwFC script (syn_namespace syn)
@@ -1500,20 +1477,20 @@ runElabDecl syn =
1501{- * Loading and parsing -}
1478{- * Loading and parsing -}
1502{-| Parses an expression from input -}
1479{-| Parses an expression from input -}
1503−parseExpr :: IState -> String -> Result PTerm
1480+parseExpr :: IState -> String -> Either ParseError PTerm
1504parseExpr st = runparser (fullExpr defaultSyntax) st "(input)"
1481parseExpr st = runparser (fullExpr defaultSyntax) st "(input)"
1506{-| Parses a constant form input -}
1483{-| Parses a constant form input -}
1507−parseConst :: IState -> String -> Result Const
1484+parseConst :: IState -> String -> Either ParseError Const
1508parseConst st = runparser (fmap fst constant) st "(input)"
1485parseConst st = runparser (fmap fst constant) st "(input)"
1510{-| Parses a tactic from input -}
1487{-| Parses a tactic from input -}
1511−parseTactic :: IState -> String -> Result PTactic
1488+parseTactic :: IState -> String -> Either ParseError PTactic
1512parseTactic st = runparser (fullTactic defaultSyntax) st "(input)"
1489parseTactic st = runparser (fullTactic defaultSyntax) st "(input)"
1514{-| Parses a do-step from input (used in the elab shell) -}
1491{-| Parses a do-step from input (used in the elab shell) -}
1515−parseElabShellStep :: IState -> String -> Result (Either ElabShellCmd PDo)
1492+parseElabShellStep :: IState -> String -> Either ParseError (Either ElabShellCmd PDo)
1516−parseElabShellStep ist = runparser (fmap Right (do_ defaultSyntax) <|> fmap Left elabShellCmd) ist "(input)"
1493+parseElabShellStep ist = runparser (Right <$> do_ defaultSyntax <|> Left <$> elabShellCmd) ist "(input)"
1517 where elabShellCmd = char ':' >>
1494 where elabShellCmd = char ':' >>
1518 (reserved "qed" >> pure EQED ) <|>
1495 (reserved "qed" >> pure EQED ) <|>
1519 (reserved "abandon" >> pure EAbandon ) <|>
1496 (reserved "abandon" >> pure EAbandon ) <|>
@@ -1525,7 +1502,7 @@ parseElabShellStep ist = runparser (fmap Right (do_ defaultSyntax) <|> fmap Left
1525 (expressionTactic ["search"] ESearch ) <|>
1502 (expressionTactic ["search"] ESearch ) <|>
1526 (do reserved "doc"
1503 (do reserved "doc"
1527 doc <- (Right . fst <$> constant) <|> (Left . fst <$> fnName)
1504 doc <- (Right . fst <$> constant) <|> (Left . fst <$> fnName)
1529 return (EDocStr doc))
1506 return (EDocStr doc))
1530 <?> "elab command"
1507 <?> "elab command"
1531 expressionTactic cmds tactic =
1508 expressionTactic cmds tactic =
@@ -1536,26 +1513,26 @@ parseElabShellStep ist = runparser (fmap Right (do_ defaultSyntax) <|> fmap Left
1536 spaced parser = indentGt *> parser
1513 spaced parser = indentGt *> parser
1538-- | Parse module header and imports
1515-- | Parse module header and imports
1539−parseImports :: FilePath -> String -> Idris (Maybe (Docstring ()), [String], [ImportInfo], Maybe Delta)
1516+parseImports :: FilePath -> String -> Idris (Maybe (Docstring ()), [String], [ImportInfo], Maybe P.Delta)
1540parseImports fname input
1517parseImports fname input
1541 = do i <- getIState
1518 = do i <- getIState
1542− case parseString (runInnerParser (evalStateT imports i)) (Directed (UTF8.fromString fname) 0 0 0 0) input of
1519+ case P.parseString (evalStateT imports i) (P.Directed (UTF8.fromString fname) 0 0 0 0) input of
1543− Failure (ErrInfo err _) -> ifail $ show err
1520+ P.Failure (P.ErrInfo err _) -> ifail $ show err
1544− Success (x, annots, i) ->
1521+ P.Success (x, annots, i) ->
1545 do putIState i
1522 do putIState i
1546 fname' <- runIO $ Dir.makeAbsolute fname
1523 fname' <- runIO $ Dir.makeAbsolute fname
1547 sendHighlighting $ addPath annots fname'
1524 sendHighlighting $ addPath annots fname'
1548 return x
1525 return x
1549 where imports :: IdrisParser ((Maybe (Docstring ()), [String],
1526 where imports :: IdrisParser ((Maybe (Docstring ()), [String],
1550 [ImportInfo],
1527 [ImportInfo],
1551− Maybe Delta),
1528+ Maybe P.Delta),
1552 [(FC, OutputAnnotation)], IState)
1529 [(FC, OutputAnnotation)], IState)
1553 imports = do optional shebang
1530 imports = do optional shebang
1554 whiteSpace
1531 whiteSpace
1555 (mdoc, mname, annots) <- moduleHeader
1532 (mdoc, mname, annots) <- moduleHeader
1556 ps_exp <- many import_
1533 ps_exp <- many import_
1557− mrk <- mark
1534+ mrk <- P.mark
1558− isEof <- lookAheadMatches eof
1535+ isEof <- lookAheadMatches P.eof
1559 let mrk' = if isEof
1536 let mrk' = if isEof
1560 then Nothing
1537 then Nothing
1561 else Just mrk
1538 else Just mrk
@@ -1572,11 +1549,11 @@ parseImports fname input
1572 addPath (annot:annots) path = annot : addPath annots path
1549 addPath (annot:annots) path = annot : addPath annots path
1574 shebang :: IdrisParser ()
1551 shebang :: IdrisParser ()
1575− shebang = string "#!" *> many (satisfy $ not . isEol) *> eol *> pure ()
1552+ shebang = string "#!" *> many (P.satisfy $ not . isEol) *> eol *> pure ()
1577-- | There should be a better way of doing this...
1554-- | There should be a better way of doing this...
1578−findFC :: Doc -> (FC, String)
1555+findFC :: PP.Doc -> (FC, String)
1579−findFC x = let s = show (plain x) in findFC' s
1556+findFC x = let s = show (PP.plain x) in findFC' s
1580 where findFC' s = case span (/= ':') s of
1557 where findFC' s = case span (/= ':') s of
1581 -- Horrid kludge to prevent crashes on Windows
1558 -- Horrid kludge to prevent crashes on Windows
1582 (prefix, ':':'\\':rest) ->
1559 (prefix, ':':'\\':rest) ->
@@ -1590,36 +1567,36 @@ findFC x = let s = show (plain x) in findFC' s
1590 (FC failname pos pos, msg)
1567 (FC failname pos pos, msg)
1592-- | Check if the coloring matches the options and corrects if necessary
1569-- | Check if the coloring matches the options and corrects if necessary
1593−fixColour :: Bool -> ANSI.Doc -> ANSI.Doc
1570+fixColour :: Bool -> PP.Doc -> PP.Doc
1594−fixColour False doc = ANSI.plain doc
1571+fixColour False doc = PP.plain doc
1595fixColour True doc = doc
1572fixColour True doc = doc
1597-- | A program is a list of declarations, possibly with associated
1574-- | A program is a list of declarations, possibly with associated
1598-- documentation strings.
1575-- documentation strings.
1599−parseProg :: SyntaxInfo -> FilePath -> String -> Maybe Delta ->
1576+parseProg :: SyntaxInfo -> FilePath -> String -> Maybe P.Delta ->
1600 Idris [PDecl]
1577 Idris [PDecl]
1601parseProg syn fname input mrk
1578parseProg syn fname input mrk
1602 = do i <- getIState
1579 = do i <- getIState
1603 case runparser mainProg i fname input of
1580 case runparser mainProg i fname input of
1604− Failure (ErrInfo doc _) -> do -- FIXME: Get error location from trifecta
1581+ Left err -> do -- FIXME: Get error location from trifecta
1605− -- this can't be the solution!
1582+ -- this can't be the solution!
1606− -- Issue #1575 on the issue tracker.
1583+ -- Issue #1575 on the issue tracker.
1607− -- https://github.com/idris-lang/Idris-dev/issues/1575
1584+ -- https://github.com/idris-lang/Idris-dev/issues/1575
1608− let (fc, msg) = findFC doc
1585+ let (fc, msg) = findFC $ parseErrorDoc err
1609− i <- getIState
1586+ i <- getIState
1610− case idris_outputmode i of
1587+ case idris_outputmode i of
1611− RawOutput h -> iputStrLn (show $ fixColour (idris_colourRepl i) doc)
1588+ RawOutput h -> iputStrLn (show . fixColour (idris_colourRepl i) . parseErrorDoc $ err)
1612− IdeMode n h -> iWarn fc (P.text msg)
1589+ IdeMode n h -> iWarn fc (Util.Pretty.text msg)
1613− putIState (i { errSpan = Just fc })
1590+ putIState (i { errSpan = Just fc })
1614− return []
1591+ return []
1615− Success (x, i) -> do putIState i
1592+ Right (x, i) -> do putIState i
1616− reportParserWarnings
1593+ reportParserWarnings
1617− return $ collect x
1594+ return $ collect x
1618 where mainProg :: IdrisParser ([PDecl], IState)
1595 where mainProg :: IdrisParser ([PDecl], IState)
1619 mainProg = case mrk of
1596 mainProg = case mrk of
1620 Nothing -> do i <- get; return ([], i)
1597 Nothing -> do i <- get; return ([], i)
1621 Just mrk -> do
1598 Just mrk -> do
1622− release mrk
1599+ P.release mrk
1623 ds <- prog syn
1600 ds <- prog syn
1624 i' <- get
1601 i' <- get
1625 return (ds, i')
1602 return (ds, i')