User-defined operators and compound expressions using Happy

Frank-Andre Riess riess at informatik.uni-muenchen.de
Wed Nov 24 09:04:32 EST 2004


> On 2004 nov 22, at 17:48, Frank-Andre Riess wrote:
>
>> Hi there folks,
>>
>> once again, I've got a question related to Happy (I've got version
>> 1.13 at
>> the moment).
>> Maybe, it's even more a question on formal languages, but well...
>> How can I write a grammar that can cope with user-defined operators (of
>> different precedences/associativities) and compound expression like
>> function calls, if-then-else- and case-statements and the like. I
>> tried to
>> write it down straight forwardly, but failed terribly (alas, I didn't
>> keep
>> it, so I can't show you - if someone of you is versed in this issue, I
>> can
>> try to explain the language's constructs).
>
> One way of doing this using combinator based parsing (where you can
> generate parsers dynamically) is to read the fixity declarations, and
> to use the result of this to build the precedence parser. This idea has
> been sketched in:
>
>   S. D. Swierstra and P. R. Azero Alcocer. Fast, Error Correcting Parser
> Combinators: a Short Tutorial. In J. Pavelka, G. Tel, and M. Bartosek,
> editors, SOFSEM'99 Theory and Practice of Informatics, 26th Seminar on
> Current Trends in Theory and Practice of Informatics, volume 1725 of
> LNCS, pages 111--129, November 1999.
>
> If you do not have access to this I will be happy to send it to you,
>
>   Doaitse Swierstra

Thank you very much. I don't know much about combinator based parsing,
however (or maybe just therefor) I'm interested in having a closer look at
it. I'd be obliged if you sent me your paper.



More information about the Glasgow-haskell-users mailing list