[Haskell-cafe] looking for alex+happy examples that uses location annotated tokens and location information in err msgs

Ömer Sinan Ağacan omeragacan at gmail.com
Sun Mar 9 11:15:02 UTC 2014


I think GHC uses alex+happy in very different way than explained in
the docs.. For example it doesn't use "posn", "monadUserState" etc.
wrappers as explained in alex documentations. I also can't figure out
how does it keep track of token locations.. I guess It's just too
complicated for me to understand without spending several hours.

---
Ömer Sinan Ağacan
http://osa1.net


2014-03-09 9:49 GMT+02:00 Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>:
> On 08/03/14 21:47, Ömer Sinan Ağacan wrote:
>> Does anyone have any example alex+happy programs that uses location
>> location annotated tokens and location information of token while
>> reporting parse errors?
>>
>> I already wrote lexer and my function type is something like:
>>
>>> runLexer :: String -> [(Token, AlexPosn)]
>>
>> where AlexPosn type contains location information. But I have no idea
>> how can I use that in happy to parse and use location information in
>> parse error messages. There are lots of examples in interwebs but as
>> far as I can see none of them works on location-annotated tokens.
>>
>> Thanks..
>>
>> ---
>> Ömer Sinan Ağacan
>> http://osa1.net
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
> I believe GHC does this. See the compiler/parser directory of the GHC
> repo. Perhaps it's not the most lightweight example but it's the only
> readily available one that I can think of.
>
> --
> Mateusz K.
> _______________________________________________
> 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