on master help sign in
WIP
commita858866cd6a35aa7f3848a63d9e2fec9c75f5228 authorJason Felice <jason.m.felice@gmail.com> dateMon 30 Oct 2017, 22:02 (9 years ago) parente148a68
3 files changed+18−15
src/Idris/Parser/Data.hs+4−4 src/Idris/Parser/Expr.hs+10−8 src/Idris/Parser/Ops.hs+4−3
src/Idris/Parser/Data.hs+4−4
@@ -22,8 +22,8 @@ import Control.Applicative
2222import Control.Monad.State.Strict
2323import Data.List
2424import Data.Maybe
25−import Text.Trifecta ((<?>))
26−import qualified Text.Trifecta as P
25+import Text.Megaparsec ((<?>))
26+import qualified Text.Megaparsec as P
2727
2828{- | Parses a record type declaration
2929Record ::=
@@ -169,7 +169,7 @@ SimpleConstructorList ::=
169169 ;
170170-}
171171data_ :: SyntaxInfo -> IdrisParser PDecl
172−data_ syn = checkDeclFixity $
172+data_ syn = (checkDeclFixity $
173173 do (doc, argDocs, acc, dataOpts) <- P.try (do
174174 (doc, argDocs) <- P.option noDocs docComment
175175 pushIndent
@@ -219,7 +219,7 @@ data_ syn = checkDeclFixity $
219219 accData acc tyn (map (\ (_, _, n, _, _, _, _) -> n) cons')
220220 return $ PData doc argDocs syn fc dataOpts (PDatadecl tyn nfc ty cons'))
221221 terminator
222− return d)
222+ return d))
223223 <?> "data type declaration"
224224 where
225225 mkPApp :: FC -> PTerm -> [PTerm] -> PTerm
src/Idris/Parser/Expr.hs+10−8
@@ -25,9 +25,11 @@ import Control.Monad.State.Strict
2525import Data.Function (on)
2626import Data.List
2727import Data.Maybe
28+import qualified Text.Parser.Token as Tok
2829import Text.Parser.Expression
2930import Text.Megaparsec ((<?>))
3031import qualified Text.Megaparsec as P
32+import qualified Text.Megaparsec.Char as P
3133
3234-- | Allow implicit type declarations
3335allowImp :: SyntaxInfo -> SyntaxInfo
@@ -1283,9 +1285,9 @@ ExprList ::=
12831285listExpr :: SyntaxInfo -> IdrisParser PTerm
12841286listExpr syn = do (FC f (l, c) _) <- getFC
12851287 lchar '['; fc <- getFC;
1286− (P.try . P.token $ do (char ']' <?> "end of list expression")
1287− (FC _ _ (l', c')) <- getFC
1288− return (mkNil (FC f (l, c) (l', c'))))
1288+ (P.try . Tok.token $ do (char ']' <?> "end of list expression")
1289+ (FC _ _ (l', c')) <- getFC
1290+ return (mkNil (FC f (l, c) (l', c'))))
12891291 <|> (do x <- expr (syn { withAppAllowed = False }) <?> "expression"
12901292 (do P.try (lchar '|') <?> "list comprehension"
12911293 qs <- P.sepBy1 (do_ syn) (lchar ',')
@@ -1467,11 +1469,11 @@ VerbatimString_t ::=
14671469@
14681470 -}
14691471verbatimStringLiteral :: IdrisParser (String, FC)
1470−verbatimStringLiteral = P.token $ do (FC f start _) <- getFC
1471− P.try $ string "\"\"\""
1472− str <- P.manyTill P.anyChar $ P.try (string "\"\"\"")
1473− (FC _ _ end) <- getFC
1474− return (str, FC f start end)
1472+verbatimStringLiteral = Tok.token $ do (FC f start _) <- getFC
1473+ P.try $ string "\"\"\""
1474+ str <- P.manyTill P.anyChar $ P.try (string "\"\"\"")
1475+ (FC _ _ end) <- getFC
1476+ return (str, FC f start end)
14751477
14761478{- | Parses a static modifier
14771479
src/Idris/Parser/Ops.hs+4−3
@@ -21,9 +21,10 @@ import Control.Monad
2121import Control.Monad.State.Strict
2222import Data.Char (isAlpha)
2323import Data.List
24+import Data.List.NonEmpty (fromList)
2425import Text.Parser.Expression
25−import Text.Trifecta ((<?>))
26−import qualified Text.Trifecta as P
26+import Text.Megaparsec ((<?>))
27+import qualified Text.Megaparsec as P
2728
2829-- | Creates table for fixity declarations to build expression parser
2930-- using pre-build and user-defined operator/fixity declarations
@@ -50,7 +51,7 @@ table fixes
5051 noFixityOperator = flip Infix AssocNone $ do
5152 indentGt
5253 op <- P.try symbolicOperator
53− P.unexpected $ "Operator without known fixity: " ++ op
54+ P.unexpected . P.Label . fromList $ "Operator without known fixity: " ++ op
5455
5556 -- | Calculates table for fixity declarations
5657 toTable :: [FixDecl] -> OperatorTable IdrisParser PTerm