on master help sign in
Be more flexible with the position of the closing bracket of a record type.
commit08ff9391748d32d4de4ae8433526d0377a66aac0 authorEvan Czaplicki <evan@Evans-MacBook-Air.local> dateSun 14 Jul 2013, 14:55 (13 years ago) parentfe7357a
2 files changed+11−4
compiler/Parse/Helpers.hs+4 compiler/Parse/Type.hs+7−4
compiler/Parse/Helpers.hs+4
@@ -156,6 +156,10 @@ forcedWS :: IParser [String]
156156forcedWS = try (do { spaces; many nl_space }) <|> try (many1 nl_space)
157157 where nl_space = try $ many1 newline >> spaces
158158
159+-- Just eats whitespace until the next meaningful character.
160+dumbWhitespace :: IParser ()
161+dumbWhitespace = many (spaces <|> newline) >> return ()
162+
159163whitespace :: IParser ()
160164whitespace = optional forcedWS <?> ""
161165
compiler/Parse/Type.hs+7−4
@@ -28,10 +28,12 @@ tuple = do ts <- parens (commaSep expr)
2828 _ -> tupleOf ts
2929
3030record :: IParser T.Type
31−record = brackets $ do
32− ext <- extend
33− fs <- fields
34− return (T.Record (fieldMap fs) ext)
31+record =
32+ do char '{' ; whitespace
33+ ext <- extend
34+ fs <- fields
35+ dumbWhitespace ; char '}'
36+ return (T.Record (fieldMap fs) ext)
3537 where
3638 extend = option T.EmptyRecord . try $ do
3739 t <- tvar
@@ -42,6 +44,7 @@ record = brackets $ do
4244 whitespace >> hasType >> whitespace
4345 (,) lbl <$> expr
4446
47+
4548constructor0 :: IParser T.Type
4649constructor0 =
4750 do name <- capVar