Re: "Circumfix" operators

Jeff Kenton <>
Tue, 11 Sep 2007 18:01:57 -0400

          From comp.compilers

Related articles
"Circumfix" operators (Joachim Durchholz) (2007-09-07)
Re: "Circumfix" operators (Jean-Marc Bourguet) (2007-09-10)
Re: "Circumfix" operators (2007-09-10)
Re: "Circumfix" operators (Jeff Kenton) (2007-09-11)
Re: "Circumfix" operators (Joachim Durchholz) (2007-09-13)
| List of all articles for this month |

From: Jeff Kenton <>
Newsgroups: comp.compilers
Date: Tue, 11 Sep 2007 18:01:57 -0400
Organization: Compilers Central
References: 07-09-020
Keywords: parse
Posted-Date: 13 Sep 2007 00:59:54 EDT

Joachim Durchholz wrote:
> I need to read up on ways to extend operator-precedence parsing to
> "circumfix" operators such as (...), [...], if...then...else... etc.

For parens and brackets you want to stack the left one immediately when
you see it and have the matching right one remove it from the stack. I
tend to do this by having a different priority value for operators when
you first see them than when they are on the stack (other ways also
work, of course). I do the same thing with the virtual
start-of-expression and end-of-expression operators.

As for if-then-else, I wouldn't add them to expression parsing unless
they are really valid in expressions, as they were in Algol or are now
in Xpath. Otherwise, I'd use a recursive descent parser for most of the
language and switch to operator precedence parsing just for expressions.


Post a followup to this message

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