mirror of
https://github.com/mrkkrp/megaparsec.git
synced 2024-12-25 17:22:33 +03:00
b062a397ee
Closes #56. In particular, file name and textual position are represented like this: filename.hs:5:6: error message This format should be more conventional, so various tools will be able to parse it and provide some support (for example, Emacs can work with this format).
24 lines
514 B
Haskell
24 lines
514 B
Haskell
|
|
module Bugs.Bug6 (main) where
|
|
|
|
import Text.Megaparsec
|
|
import Text.Megaparsec.String
|
|
|
|
import Test.Framework
|
|
import Test.Framework.Providers.HUnit
|
|
import Test.HUnit hiding (Test)
|
|
|
|
import Util
|
|
|
|
main :: Test
|
|
main =
|
|
testCase "Look-ahead preserving error location (#6)" $
|
|
parseErrors variable "return" @?= [" 'return' is a reserved keyword"]
|
|
|
|
variable :: Parser String
|
|
variable = do
|
|
x <- lookAhead (some letterChar)
|
|
if x == "return"
|
|
then fail "'return' is a reserved keyword"
|
|
else string x
|