[Haskell-cafe] [Haskell] ANNOUNCE: haskell-src-exts 1.14.0

Tommy Thorn tt1729 at yahoo.com
Wed Aug 21 07:09:52 CEST 2013


+1

When I worked on the font-lock support for haskell-mode, the irony
of trying to approximate the classification that the hugs/ghc/whatnot parser
was already doing wasn't lost on me.  I still would like to tap into more
of the knowledge generated and lost in the compiler:

- A list of all tokens (source position, span, classification). Comments are conventionally
  treated as whitespace, but it's not very hard to capture them before dropping
  them.

- All identifiers can be classified into def and use with enough lexical scope information
  to get from use to def and from def to all uses. Take this one step further and type
  information can be stored with the def.

- Tokens should be mapped to the underlying AST if possible, and vice versa.

I'm sure there's more, but with this, one could build an awesome editor, code navigator.

I think it's possible, but I don't have time to work on it, alas. I'd like suggestions as to
to realize this.

Tommy -- ponding hacking the parser combinators to keep this information.





On Aug 20, 2013, at 03:00 , Niklas Hambüchen <mail at nh2.me> wrote:

> On 20/08/13 18:19, Niklas Broberg wrote:
>> Sadly not - it's theoretically impossible. The fact that you can put
>> comments literally wherever, means that it's impossible to treat them as
>> nodes of the AST. E.g.
>> 
>>  f {- WHERE -} x = -- WOULD
>>      -- THESE
>>      do -- COMMENTS
>>         a {- END -} <- g x -- UP
>>         return {- ? -} a
> 
> Oh, I see what you mean.
> 
> I guess what I mean instead is:
> 
> * A lex list that contains *everything*, including comments and white space
> 
> * A full syntax tree of which each node points to (indexes) a position
> in the lex list to get the precise original position; comments in
> between two nodes can then be determined and more easily played with
> because they are between their positions in the lex list
> 
> * An abstract syntax tree that has whitespace and comments discarded
> (what HSE has now)
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe





More information about the Haskell-Cafe mailing list