Re: variable lookahead in cup? Please help.

haberg@matematik.su.se (Hans Aberg)
23 Aug 2003 23:10:48 -0400

          From comp.compilers

Related articles
variable lookahead in cup? Please help. Martin.Hampl@stud.uni-erlangen.de (2003-08-20)
Re: variable lookahead in cup? Please help. Martin.Hampl@stud.uni-erlangen.de (2003-08-23)
Re: variable lookahead in cup? Please help. haberg@matematik.su.se (2003-08-23)
| List of all articles for this month |
From: haberg@matematik.su.se (Hans Aberg)
Newsgroups: comp.compilers
Date: 23 Aug 2003 23:10:48 -0400
Organization: Mathematics
References: 03-08-063
Keywords: parse
Posted-Date: 23 Aug 2003 23:10:48 EDT

Martin.Hampl@stud.uni-erlangen.de (Martin) wrote:


>I am trying to write a Paser for a simple language. I'd like it to parse
>the expression 'STRING = STRING & STRING' like STRING = (STRING &
>STRING)' but 'STRING = STRING & STRING = STRING' like (STRING = STRING)
>& (STRING = STRING).


This seems to be poor practise, as in the first case & has higher
precedence than =, and in the other case, it is the reverse. It is better
to keep precedences fixed, if possible. Even though I recently found a
funny exception:


In a proof verification language I use the both cases
        all x A
        all x: <formula>
Here, the first case is the traditional notation, but it requires on to
use a lot of parenthesizes, which looks heavy in a language. So I
introduced the second one. It then turns out that the two operators "all
x" and "all x:" have different precedences.


But you can see the language design criteria I use. Also, the two
different precedences have different notational forms.


    Hans Aberg * Anti-spam: remove "remove." from email address.
                                    * Email: Hans Aberg <remove.haberg@member.ams.org>
                                    * Home Page: <http://www.math.su.se/~haberg/>
                                    * AMS member listing: <http://www.ams.org/cml/>


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.