on master help sign in
Add support for triple-quoted multi-line strings
commit9d68c10683b3dfa394637fd390d7a50e5ceb8be6 authorEvan Czaplicki <evan@Evans-MacBook-Air.local> dateThu 27 Jun 2013, 18:55 (13 years ago) parentd91419d
2 files changed+6−3
compiler/Parse/Literal.hs+5−2 compiler/Parse/Pattern.hs+1−1
compiler/Parse/Literal.hs+5−2
@@ -20,8 +20,11 @@ num = fmap toLit (preNum <?> "number")
2020 ('.':) <$> many1 digit
2121
2222str :: IParser Literal
23−str = liftM Str . expecting "string" . betwixt '"' '"' . many $
24− backslashed <|> satisfy (/='"')
23+str = choice [ let quote = try (string "\"\"\"")
24+ in quote >> Str <$> manyTill (backslashed <|> anyChar) quote
25+ , liftM Str . expecting "string" . betwixt '"' '"' . many $
26+ backslashed <|> satisfy (/='"')
27+ ]
2528
2629chr :: IParser Literal
2730chr = Chr <$> betwixt '\'' '\'' (backslashed <|> satisfy (/='\''))
compiler/Parse/Pattern.hs+1−1
@@ -1,7 +1,7 @@
11
22module Parse.Pattern (term, expr, makeLambda, flatten) where
33
4−import Control.Applicative ((<$>),(<*>),(*>),pure)
4+import Control.Applicative ((<$>),(<*>),pure)
55import Control.Monad
66import Control.Monad.State
77import Data.Char (isUpper)