From 664ae3b6279b0001e699b9d7fd24ec47a1cf0af8 Mon Sep 17 00:00:00 2001 From: Colin Wahl Date: Mon, 6 Apr 2020 21:38:58 -0700 Subject: [PATCH 1/5] ErrQualifierLexeme --- lib/purescript-cst/src/Language/PureScript/CST/Errors.hs | 5 +++++ lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs b/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs index 18ed7079ee..c6fc4fe18f 100644 --- a/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs +++ b/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs @@ -53,6 +53,7 @@ data ParserErrorType | ErrQualifiedName | ErrEmptyDo | ErrLexeme (Maybe String) [String] + | ErrQualifierLexeme Char | ErrEof | ErrCustom String deriving (Show, Eq, Ord) @@ -128,6 +129,10 @@ prettyPrintErrorMessage (ParserErrorInfo {..}) = case errType of "Illegal whitespace character " <> displayCodePoint hd ErrLexeme (Just a) _ -> "Unexpected " <> a + ErrQualifierLexeme hd | isSpace hd -> + "Unexpected whitespace character " <> displayCodePoint hd <> ", expected qualifier" + ErrQualifierLexeme a -> + "Unexpected" <> [ a ] <> ", expected qualifier" ErrLineFeedInString -> "Unexpected line feed in string literal" ErrAstralCodePointInChar -> diff --git a/lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs b/lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs index 2ad7646479..94dda64d71 100644 --- a/lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs +++ b/lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs @@ -357,7 +357,7 @@ token = peek >>= maybe (pure TokEof) k0 | Char.isUpper ch2 -> next *> upper qual' ch2 | isIdentStart ch2 -> next *> lower qual' ch2 | isSymbolChar ch2 -> next *> operator qual' [ch2] - | otherwise -> throw $ ErrLexeme (Just [ch2]) [] + | otherwise -> throw $ ErrQualifierLexeme ch2 Nothing -> throw ErrEof _ -> From 139007984153097c00548b9dfb379af4b3ed046d Mon Sep 17 00:00:00 2001 From: Colin Wahl Date: Sun, 12 Apr 2020 13:07:32 -0700 Subject: [PATCH 2/5] space --- .../src/Language/PureScript/CST/Errors.hs | 2 +- stack.yaml.lock | 47 +++++++++++++++++++ tests/purs/failing/3801.out | 10 ++++ tests/purs/failing/3801.purs | 7 +++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 stack.yaml.lock create mode 100644 tests/purs/failing/3801.out create mode 100644 tests/purs/failing/3801.purs diff --git a/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs b/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs index c6fc4fe18f..391d42255d 100644 --- a/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs +++ b/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs @@ -132,7 +132,7 @@ prettyPrintErrorMessage (ParserErrorInfo {..}) = case errType of ErrQualifierLexeme hd | isSpace hd -> "Unexpected whitespace character " <> displayCodePoint hd <> ", expected qualifier" ErrQualifierLexeme a -> - "Unexpected" <> [ a ] <> ", expected qualifier" + "Unexpected " <> [ a ] <> ", expected qualifier" ErrLineFeedInString -> "Unexpected line feed in string literal" ErrAstralCodePointInChar -> diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000000..9fb35a773c --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,47 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: +- completed: + hackage: happy-1.19.9@sha256:f8c774230735a390c287b2980cfcd2703d24d8dde85a01ea721b7b4b4c82944f,4667 + pantry-tree: + size: 7980 + sha256: 1f1d622f6e773e7a674da6364b755714c76c3fbb3c7a4e65deaf07242fc15211 + original: + hackage: happy-1.19.9 +- completed: + hackage: language-javascript-0.7.0.0@sha256:3eab0262b8ac5621936a4beab6a0f97d0e00a63455a8b0e3ac1547b4088dae7d,3898 + pantry-tree: + size: 2244 + sha256: b0f28d836cb3fbde203fd7318a896c3a20acd8653a905e1950ae2d9a64bccebf + original: + hackage: language-javascript-0.7.0.0 +- completed: + hackage: network-3.0.1.1@sha256:1a251b790ea98b6f7433f677958f921950780ba6f143d61ba8c0e3f7a9879097,4074 + pantry-tree: + size: 3296 + sha256: 78e378780c998faaf4e32a16b98880220f502d8ef005f24d7ee0c99fb50636e6 + original: + hackage: network-3.0.1.1 +- completed: + hackage: these-1.0.1@sha256:7ff0f309978604015d978fb155ac4dc10a98e3d70a99aa2be8f755eb0cca4324,3191 + pantry-tree: + size: 351 + sha256: 3257ef64424e9a07e2ae750eff7affcd459811c4669cb67a5e4f43ab833c5aba + original: + hackage: these-1.0.1 +- completed: + hackage: semialign-1@sha256:f11b3d8d0f31a3556061ec0fb515575646d162f12c5b25a0f07c92679db7d862,2433 + pantry-tree: + size: 466 + sha256: e67b833b94b7fa23afbf7088833a38596cf35a2b93635604dd9e49d0389360fe + original: + hackage: semialign-1 +snapshots: +- completed: + size: 499889 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/26.yaml + sha256: ecb02ee16829df8d7219e7d7fe6c310819820bf335b0b9534bce84d3ea896684 + original: lts-13.26 diff --git a/tests/purs/failing/3801.out b/tests/purs/failing/3801.out new file mode 100644 index 0000000000..8e2d047f94 --- /dev/null +++ b/tests/purs/failing/3801.out @@ -0,0 +1,10 @@ +Error found: +at tests/purs/failing/3801.purs:6:13 - 6:14 (line 6, column 13 - line 6, column 14) + + Unable to parse module: + Unexpected whitespace character U+000A, expected qualifier + + +See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information, +or to contribute content related to this error. + diff --git a/tests/purs/failing/3801.purs b/tests/purs/failing/3801.purs new file mode 100644 index 0000000000..0242a69425 --- /dev/null +++ b/tests/purs/failing/3801.purs @@ -0,0 +1,7 @@ +-- @shouldFailWith ErrQualifierLexeme +module Main where + +import Prelude as Prelude + +x :: Int +x = Prelude. From bdf410b3f9e6306d136d4155fee61442953ccfae Mon Sep 17 00:00:00 2001 From: Colin Wahl Date: Sun, 12 Apr 2020 13:07:57 -0700 Subject: [PATCH 3/5] Revert "space" This reverts commit 139007984153097c00548b9dfb379af4b3ed046d. --- .../src/Language/PureScript/CST/Errors.hs | 2 +- stack.yaml.lock | 47 ------------------- tests/purs/failing/3801.out | 10 ---- tests/purs/failing/3801.purs | 7 --- 4 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 stack.yaml.lock delete mode 100644 tests/purs/failing/3801.out delete mode 100644 tests/purs/failing/3801.purs diff --git a/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs b/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs index 391d42255d..c6fc4fe18f 100644 --- a/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs +++ b/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs @@ -132,7 +132,7 @@ prettyPrintErrorMessage (ParserErrorInfo {..}) = case errType of ErrQualifierLexeme hd | isSpace hd -> "Unexpected whitespace character " <> displayCodePoint hd <> ", expected qualifier" ErrQualifierLexeme a -> - "Unexpected " <> [ a ] <> ", expected qualifier" + "Unexpected" <> [ a ] <> ", expected qualifier" ErrLineFeedInString -> "Unexpected line feed in string literal" ErrAstralCodePointInChar -> diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index 9fb35a773c..0000000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,47 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: -- completed: - hackage: happy-1.19.9@sha256:f8c774230735a390c287b2980cfcd2703d24d8dde85a01ea721b7b4b4c82944f,4667 - pantry-tree: - size: 7980 - sha256: 1f1d622f6e773e7a674da6364b755714c76c3fbb3c7a4e65deaf07242fc15211 - original: - hackage: happy-1.19.9 -- completed: - hackage: language-javascript-0.7.0.0@sha256:3eab0262b8ac5621936a4beab6a0f97d0e00a63455a8b0e3ac1547b4088dae7d,3898 - pantry-tree: - size: 2244 - sha256: b0f28d836cb3fbde203fd7318a896c3a20acd8653a905e1950ae2d9a64bccebf - original: - hackage: language-javascript-0.7.0.0 -- completed: - hackage: network-3.0.1.1@sha256:1a251b790ea98b6f7433f677958f921950780ba6f143d61ba8c0e3f7a9879097,4074 - pantry-tree: - size: 3296 - sha256: 78e378780c998faaf4e32a16b98880220f502d8ef005f24d7ee0c99fb50636e6 - original: - hackage: network-3.0.1.1 -- completed: - hackage: these-1.0.1@sha256:7ff0f309978604015d978fb155ac4dc10a98e3d70a99aa2be8f755eb0cca4324,3191 - pantry-tree: - size: 351 - sha256: 3257ef64424e9a07e2ae750eff7affcd459811c4669cb67a5e4f43ab833c5aba - original: - hackage: these-1.0.1 -- completed: - hackage: semialign-1@sha256:f11b3d8d0f31a3556061ec0fb515575646d162f12c5b25a0f07c92679db7d862,2433 - pantry-tree: - size: 466 - sha256: e67b833b94b7fa23afbf7088833a38596cf35a2b93635604dd9e49d0389360fe - original: - hackage: semialign-1 -snapshots: -- completed: - size: 499889 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/26.yaml - sha256: ecb02ee16829df8d7219e7d7fe6c310819820bf335b0b9534bce84d3ea896684 - original: lts-13.26 diff --git a/tests/purs/failing/3801.out b/tests/purs/failing/3801.out deleted file mode 100644 index 8e2d047f94..0000000000 --- a/tests/purs/failing/3801.out +++ /dev/null @@ -1,10 +0,0 @@ -Error found: -at tests/purs/failing/3801.purs:6:13 - 6:14 (line 6, column 13 - line 6, column 14) - - Unable to parse module: - Unexpected whitespace character U+000A, expected qualifier - - -See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information, -or to contribute content related to this error. - diff --git a/tests/purs/failing/3801.purs b/tests/purs/failing/3801.purs deleted file mode 100644 index 0242a69425..0000000000 --- a/tests/purs/failing/3801.purs +++ /dev/null @@ -1,7 +0,0 @@ --- @shouldFailWith ErrQualifierLexeme -module Main where - -import Prelude as Prelude - -x :: Int -x = Prelude. From eb07003d0edcfabbcc414592118bb2ddb1a045a1 Mon Sep 17 00:00:00 2001 From: Colin Wahl Date: Sun, 12 Apr 2020 13:08:11 -0700 Subject: [PATCH 4/5] space --- lib/purescript-cst/src/Language/PureScript/CST/Errors.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs b/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs index c6fc4fe18f..391d42255d 100644 --- a/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs +++ b/lib/purescript-cst/src/Language/PureScript/CST/Errors.hs @@ -132,7 +132,7 @@ prettyPrintErrorMessage (ParserErrorInfo {..}) = case errType of ErrQualifierLexeme hd | isSpace hd -> "Unexpected whitespace character " <> displayCodePoint hd <> ", expected qualifier" ErrQualifierLexeme a -> - "Unexpected" <> [ a ] <> ", expected qualifier" + "Unexpected " <> [ a ] <> ", expected qualifier" ErrLineFeedInString -> "Unexpected line feed in string literal" ErrAstralCodePointInChar -> From 9adc63a4f9b29e80b40411fbfcb9a18785d8c39a Mon Sep 17 00:00:00 2001 From: Colin Wahl Date: Sun, 12 Apr 2020 13:12:06 -0700 Subject: [PATCH 5/5] remove extra space in arg --- lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs b/lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs index 94dda64d71..a0e7ac0600 100644 --- a/lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs +++ b/lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs @@ -357,7 +357,7 @@ token = peek >>= maybe (pure TokEof) k0 | Char.isUpper ch2 -> next *> upper qual' ch2 | isIdentStart ch2 -> next *> lower qual' ch2 | isSymbolChar ch2 -> next *> operator qual' [ch2] - | otherwise -> throw $ ErrQualifierLexeme ch2 + | otherwise -> throw $ ErrQualifierLexeme ch2 Nothing -> throw ErrEof _ ->