@@ -72,16 +72,18 @@ instance Text.Parser.Char.CharParsing IdrisInnerParser where
72 char = P.char
72 char = P.char
73 string = P.string
73 string = P.string
75−instance {-# OVERLAPPING #-} Tok.TokenParsing IdrisParser where
75+tokenFC :: IdrisParser a -> IdrisParser (a, FC)
76− someSpace = someSpace'
77− token p = do s <- get
76+tokenFC p = do s <- get
78 (FC fn (sl, sc) _) <- getFC --TODO: Update after fixing getFC
77 (FC fn (sl, sc) _) <- getFC --TODO: Update after fixing getFC
79 -- See Issue #1594
78 -- See Issue #1594
81 (FC fn _ (el, ec)) <- getFC
80 (FC fn _ (el, ec)) <- getFC
82 whiteSpace
81 whiteSpace
83− put (s { lastTokenSpan = Just (FC fn (sl, sc) (el, ec)) })
82+ return (r, FC fn (sl, sc) (el, ec))
84+instance {-# OVERLAPPING #-} Tok.TokenParsing IdrisParser where
85+ someSpace = someSpace'
86+ token p = p <* whiteSpace
86-- | Helper to run Idris inner parser based stateT parsers
88-- | Helper to run Idris inner parser based stateT parsers
87runparser :: StateT st IdrisInnerParser res -> st -> String -> String -> Either ParseError res
89runparser :: StateT st IdrisInnerParser res -> st -> String -> String -> Either ParseError res
@@ -227,27 +229,21 @@ whiteSpace = someSpace' <|> pure ()
228-- | Parses a string literal
230-- | Parses a string literal
229stringLiteral :: IdrisParser (String, FC)
231stringLiteral :: IdrisParser (String, FC)
230−stringLiteral = do str <- Tok.stringLiteral
232+stringLiteral = tokenFC . P.try $ P.char '"' *> P.manyTill P.charLiteral (P.char '"')
231− fc <- lastTokenSpan <$> get
232− return (str, fromMaybe NoFC fc)
234-- | Parses a char literal
234-- | Parses a char literal
235charLiteral :: IdrisParser (Char, FC)
235charLiteral :: IdrisParser (Char, FC)
236−charLiteral = do ch <- Tok.charLiteral
236+charLiteral = tokenFC . P.try $ P.char '\'' *> P.charLiteral <* P.char '\''
237− fc <- lastTokenSpan <$> get
238− return (ch, fromMaybe NoFC fc)
240-- | Parses a natural number
238-- | Parses a natural number
241natural :: IdrisParser (Integer, FC)
239natural :: IdrisParser (Integer, FC)
242−natural = do n <- Tok.natural
240+natural = tokenFC ( P.try (P.char '0' *> P.char' 'x' *> P.hexadecimal)
243− fc <- lastTokenSpan <$> get
241+ <|> P.try (P.char '0' *> P.char' 'o' *> P.octal)
244− return (n, fromMaybe NoFC fc)
242+ <|> P.try P.decimal)
246-- | Parses a floating point number
244-- | Parses a floating point number
247float :: IdrisParser (Double, FC)
245float :: IdrisParser (Double, FC)
248−float = do f <- Tok.double
246+float = tokenFC . P.try $ P.float
249− fc <- lastTokenSpan <$> get
250− return (f, fromMaybe NoFC fc)
252{- * Symbols, identifiers, names and operators -}
248{- * Symbols, identifiers, names and operators -}