@@ -240,12 +240,19 @@ parseToken = P.choice
240240 parseStringLiteral :: P.Parsec String u String
241241 parseStringLiteral = blockString <|> PT.stringLiteral tokenParser
242242 where
243− delimeter = P.try (P.string "\"\"\"")
244− blockString = delimeter >> P.manyTill P.anyChar delimeter
243+ delimiter = P.try (P.string "\"\"\"")
244+ blockString = delimiter >> P.manyTill P.anyChar delimiter
245245
246246 parseNumber :: P.Parsec String u (Either Integer Double)
247− parseNumber = (Right <$> P.try (PT.float tokenParser) <|>
248− Left <$> P.try (PT.natural tokenParser)) P.<?> "number"
247+ parseNumber = (consumeLeadingZero >> P.parserZero) <|>
248+ (Right <$> P.try (PT.float tokenParser) <|>
249+ Left <$> P.try (PT.natural tokenParser))
250+ P.<?> "number"
251+ where
252+ -- lookAhead doesn't consume any input if its parser succeeds
253+ -- if notFollowedBy fails though, the consumed '0' will break the choice chain
254+ consumeLeadingZero = P.lookAhead (P.char '0' >>
255+ (P.notFollowedBy P.digit P.<?> "no leading zero in number literal"))
249256
250257-- |
251258-- We use Text.Parsec.Token to implement the string and number lexemes