on master help sign in
Merge pull request #779 from ahmadsalim/feature/multilineliterals
f24ae1dEdwin Brady
src/Idris/ParseExpr.hs+12
@@ -987,6 +987,7 @@ Constant ::=
987 | 'Bits64x2'
987 | 'Bits64x2'
988 | Float_t
988 | Float_t
989 | Natural_t
989 | Natural_t
990+ | VerbatimString_t
990 | String_t
991 | String_t
991 | Char_t
992 | Char_t
992 ;
993 ;
@@ -1009,10 +1010,21 @@ constant = do reserved "Integer";return (AType (ATInt ITBig))
1009 <|> do reserved "Bits64x2"; return (AType (ATInt (ITVec IT64 2)))
1010 <|> do reserved "Bits64x2"; return (AType (ATInt (ITVec IT64 2)))
1010 <|> try (do f <- float; return $ Fl f)
1011 <|> try (do f <- float; return $ Fl f)
1011 <|> try (do i <- natural; return $ BI i)
1012 <|> try (do i <- natural; return $ BI i)
1013+ <|> try (do s <- verbatimStringLiteral; return $ Str s)
1012 <|> try (do s <- stringLiteral; return $ Str s)
1014 <|> try (do s <- stringLiteral; return $ Str s)
1013 <|> try (do c <- charLiteral; return $ Ch c)
1015 <|> try (do c <- charLiteral; return $ Ch c)
1014 <?> "constant or literal"
1016 <?> "constant or literal"
1015
1017
1018+{- | Parses a verbatim multi-line string literal (triple-quoted)
1019+@
1020+VerbatimString_t ::=
1021+ '"""' ~'"""' '"""'
1022+@
1023+ -}
1024+verbatimStringLiteral :: MonadicParsing m => m String
1025+verbatimStringLiteral = token $ do string "\"\"\""
1026+ manyTill anyChar $ try (string "\"\"\"")
1027+
1016{- | Parses a static modifier
1028{- | Parses a static modifier
1017
1029
1018@
1030@