
Hello fellow Haskellers, In EclipseFP we use the GHC API for IDE related stuff like syntax highlighting and code outlines. However, I ran into something funny yesterday: when a source file contains LINE pragmas ( http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/pragmas.html#line-pr...), all the locations for tokens are changed to reflect the pragmas information. While this is great in the "normal' GHC usage, this is not so great for us, because we're interested in that source code, not in original code. I haven't seen any flag to turn that behavior off in the docs, nor in the Lexer code, but have I missed something? Can I tell GHC to just ignore these pragmas? I suppose even using GHC for building and something else (haskell-src-exts?) for code handling would leave us with compilation messages at the wrong place. Thanks, -- JP Moresmau http://jpmoresmau.blogspot.com/

On Fri, Sep 10, 2010 at 1:40 AM, JP Moresmau
Hello fellow Haskellers, In EclipseFP we use the GHC API for IDE related stuff like syntax highlighting and code outlines. However, I ran into something funny yesterday: when a source file contains LINE pragmas (http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/pragmas.html#line-pr...), all the locations for tokens are changed to reflect the pragmas information. While this is great in the "normal' GHC usage, this is not so great for us, because we're interested in that source code, not in original code. I haven't seen any flag to turn that behavior off in the docs, nor in the Lexer code, but have I missed something? Can I tell GHC to just ignore these pragmas? I suppose even using GHC for building and something else (haskell-src-exts?) for code handling would leave us with compilation messages at the wrong place. Thanks,
Would you turn the behavior back on when editing .hsc files or something similar?

Well, in an editor, there some operations that operate on solely on a file,
and some at the project level. I would make sense to me if typechecking
errors were reported against the original file (following the pragmas) while
lexing and outlining results would operate without (on the actual file
contents).
JP
On Fri, Sep 10, 2010 at 2:13 PM, Antoine Latter
Hello fellow Haskellers, In EclipseFP we use the GHC API for IDE related stuff like syntax highlighting and code outlines. However, I ran into something funny yesterday: when a source file contains LINE pragmas ( http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/pragmas.html#line-pr... ), all the locations for tokens are changed to reflect the pragmas information. While this is great in the "normal' GHC usage, this is not so great for us, because we're interested in that source code, not in original code. I haven't seen any flag to turn that behavior off in the docs, nor in the Lexer code, but have I missed something? Can I tell GHC to just ignore
On Fri, Sep 10, 2010 at 1:40 AM, JP Moresmau
wrote: these pragmas? I suppose even using GHC for building and something else (haskell-src-exts?) for code handling would leave us with compilation messages at the wrong place. Thanks,
Would you turn the behavior back on when editing .hsc files or something similar?
-- JP Moresmau http://jpmoresmau.blogspot.com/

On Fri, Sep 10, 2010 at 7:40 AM, JP Moresmau
I suppose even using GHC for building and something else (haskell-src-exts?) for code handling would leave us with compilation messages at the wrong place.
I don't quite understand your use case so I'm not sure it helps, but for what it's worth haskell-src-exts allows you to ignore line pragmas while parsing: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.9.0/doc/html/...

On Fri, 10 Sep 2010 08:40:22 +0200, JP Moresmau
Can I tell GHC to just ignore these pragmas? I suppose even using GHC for building and something else (haskell-src-exts?) for code handling would leave us with compilation messages at the wrong place.
Thanks,
Maybe you could try something like #ifdef USE_LINE_PRAGMAS {-# LINE 42 "Foo.lhs" #-} #endif Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --

JP Moresmau schrieb:
Hello fellow Haskellers,
In EclipseFP we use the GHC API for IDE related stuff like syntax highlighting and code outlines. However, I ran into something funny yesterday: when a source file contains LINE pragmas (http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/pragmas.html#line-pr...), all the locations for tokens are changed to reflect the pragmas information.
I thought that files that contain the LINE pragma usually are automatically generated files. Why would you want to edit or maintain such files in an IDE?

Users may not want to edit the files directly, but they'll be happy to be able to open them with proper syntax highlighting, for example. JP On Sat, Sep 11, 2010 at 7:57 PM, Henning Thielemann < schlepptop@henning-thielemann.de> wrote:
JP Moresmau schrieb:
Hello fellow Haskellers,
In EclipseFP we use the GHC API for IDE related stuff like syntax highlighting and code outlines. However, I ran into something funny yesterday: when a source file contains LINE pragmas ( http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/pragmas.html#line-pr... ), all the locations for tokens are changed to reflect the pragmas information.
I thought that files that contain the LINE pragma usually are automatically generated files. Why would you want to edit or maintain such files in an IDE?
-- JP Moresmau http://jpmoresmau.blogspot.com/
participants (5)
-
Antoine Latter
-
Ben Millwood
-
Henk-Jan van Tuyl
-
Henning Thielemann
-
JP Moresmau