on master help sign in
Merge pull request #779 from ahmadsalim/feature/multilineliterals

Adds support for triple-quoted possibly multi-line verbatim string literals

commitf24ae1d55190c1d510d579e8c15fd904c333e6bb authorEdwin Brady <edwin.brady@gmail.com> dateTue 14 Jan 2014, 08:37 (13 years ago) parent05524a1f9332e0
1 file changed+12
src/Idris/ParseExpr.hs+12
src/Idris/ParseExpr.hs+12
@@ -987,6 +987,7 @@ Constant ::=
987987 | 'Bits64x2'
988988 | Float_t
989989 | Natural_t
990+ | VerbatimString_t
990991 | String_t
991992 | Char_t
992993 ;
@@ -1009,10 +1010,21 @@ constant = do reserved "Integer";return (AType (ATInt ITBig))
10091010 <|> do reserved "Bits64x2"; return (AType (ATInt (ITVec IT64 2)))
10101011 <|> try (do f <- float; return $ Fl f)
10111012 <|> try (do i <- natural; return $ BI i)
1013+ <|> try (do s <- verbatimStringLiteral; return $ Str s)
10121014 <|> try (do s <- stringLiteral; return $ Str s)
10131015 <|> try (do c <- charLiteral; return $ Ch c)
10141016 <?> "constant or literal"
10151017
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+
10161028{- | Parses a static modifier
10171029
10181030@