on master help sign in
fix #279
115b139Evan Czaplicki
compiler/Parse/Literal.hs+4−1
@@ -14,10 +14,13 @@ num :: IParser Literal
14num = fmap toLit (preNum <?> "number")
14num = fmap toLit (preNum <?> "number")
15 where toLit n | '.' `elem` n = FloatNum (read n)
15 where toLit n | '.' `elem` n = FloatNum (read n)
16 | otherwise = IntNum (read n)
16 | otherwise = IntNum (read n)
17− preNum = (++) <$> many1 digit <*> option "" postNum
17+ preNum = concat <$> sequence [ option "" minus, many1 digit, option "" postNum ]
18 postNum = do try $ lookAhead (string "." >> digit)
18 postNum = do try $ lookAhead (string "." >> digit)
19 string "."
19 string "."
20 ('.':) <$> many1 digit
20 ('.':) <$> many1 digit
21+ minus = try $ do string "-"
22+ lookAhead digit
23+ return "-"
21
24
22chr :: IParser Literal
25chr :: IParser Literal
23chr = Chr <$> betwixt '\'' '\'' (backslashed <|> satisfy (/='\''))
26chr = Chr <$> betwixt '\'' '\'' (backslashed <|> satisfy (/='\''))