Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optF pragma incorrectly parsed #382

Closed
Sir4ur0n opened this Issue Feb 8, 2019 · 12 comments

Comments

Projects
None yet
3 participants
@Sir4ur0n
Copy link
Contributor

Sir4ur0n commented Feb 8, 2019

Based on tasty-discover documentation and GHC spec, the string following -optF should be passed to the preprocessor.

Intellij Haskell incorrectly interprets options containing -- in a pragma, example:

{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --tree-display #-}

The error is

Error:(1, 4) HaskellTokenType.CON_ID, HaskellTokenType.DIRECTIVE or HaskellTokenType.NEWLINE expected, got 'OPTIONS_GHC'

image

@Sir4ur0n

This comment has been minimized.

Copy link
Contributor Author

Sir4ur0n commented Feb 8, 2019

Surprisingly this seems to work fine with new lines:

{-# OPTIONS_GHC
  -F -pgmF tasty-discover -optF --tree-display
 #-}
@rikvdkleij

This comment has been minimized.

Copy link
Owner

rikvdkleij commented Feb 8, 2019

Thanks for reporting! Will fix it.

@rikvdkleij

This comment has been minimized.

Copy link
Owner

rikvdkleij commented Feb 11, 2019

Okay, this was really an unexpected struggle to get fixed. Problem is that parser sees everything that starts with -- as comment.

Got a proper solution at the cost of no code completion within the pragma.

rikvdkleij added a commit that referenced this issue Feb 11, 2019

@rikvdkleij

This comment has been minimized.

Copy link
Owner

rikvdkleij commented Feb 12, 2019

@ice1000 Do you know a better solution?

@ice1000

This comment has been minimized.

Copy link
Contributor

ice1000 commented Feb 12, 2019

Yes, create a lexer state and parse everything inside the pragma as some trivial tokens

@rikvdkleij

This comment has been minimized.

Copy link
Owner

rikvdkleij commented Feb 12, 2019

@ice1000
That's not clear for me, Can you give example?

@rikvdkleij

This comment has been minimized.

Copy link
Owner

rikvdkleij commented Feb 13, 2019

@ice1000

On a second thought, that's what I already implemented as solution for this issue. See the commit. The point is that the whole options_ghc pragma is one big token. So I thought, maybe you know a better solution.

@ice1000

This comment has been minimized.

Copy link
Contributor

ice1000 commented Feb 13, 2019

@rikvdkleij I'll try to elaborate my solution with a PR.

@rikvdkleij

This comment has been minimized.

Copy link
Owner

rikvdkleij commented Feb 16, 2019

@ice1000 Many thanks in advance!

I do not want to push but any idea when you can create a PR?

@ice1000

This comment has been minimized.

Copy link
Contributor

ice1000 commented Feb 16, 2019

This weekend.

@ice1000

This comment has been minimized.

Copy link
Contributor

ice1000 commented Feb 17, 2019

I see some garbage lexical tokens like HS_DOUBLE_QUOTE. These are no longer used but kept general_pragma_content..

@ice1000

This comment has been minimized.

Copy link
Contributor

ice1000 commented Feb 17, 2019

Checkout my PR. I hope I'm not making stupid mistakes.

Bomb my PR with edge cases!

rikvdkleij added a commit that referenced this issue Feb 17, 2019

Merge pull request #387 from ice1k/new-pragma-parser
Implement new parser, close #382, close #332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.