Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/purescript-cst/src/Language/PureScript/CST/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ data ParserErrorType
| ErrQualifiedName
| ErrEmptyDo
| ErrLexeme (Maybe String) [String]
| ErrQualifierLexeme Char
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By analogy with ErrImportInDecl, ErrTypeInConstraint, etc., should this be ErrLexemeInQualified?

| ErrEof
| ErrCustom String
deriving (Show, Eq, Ord)
Expand Down Expand Up @@ -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"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you mean ‘expected identifier or operator’ instead of ‘expected qualifier’? The qualifier has already been seen at this point in the parse, right?

Also, it looks like the other error messages of this nature follow an ‘Expected X, saw Y’ pattern; I'd expect these messages to match that.

ErrQualifierLexeme a ->
"Unexpected " <> [ a ] <> ", expected qualifier"
ErrLineFeedInString ->
"Unexpected line feed in string literal"
ErrAstralCodePointInChar ->
Expand Down
2 changes: 1 addition & 1 deletion lib/purescript-cst/src/Language/PureScript/CST/Lexer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
_ ->
Expand Down