Home > Archive > Compilers > September 2007 > "Circumfix" operators
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
"Circumfix" operators
|
|
| Joachim Durchholz 2007-09-08, 4:23 am |
| Hi all,
I need to read up on ways to extend operator-precedence parsing to
"circumfix" operators such as (...), [...], if...then...else... etc.
My knowledge of operator-precedence parsing is mostly at the Dragon Book
level.
Any solid overview that covers the design options and lists their
trade-offs would be helpful.
TIA.
Regards,
Jo
| |
| Jean-Marc Bourguet 2007-09-10, 7:13 pm |
| Joachim Durchholz <jo@durchholz.org> writes:
> I need to read up on ways to extend operator-precedence parsing to
> "circumfix" operators such as (...), [...], if...then...else... etc.
>
> My knowledge of operator-precedence parsing is mostly at the Dragon Book
> level. Any solid overview that covers the design options and lists their
> trade-offs would be helpful.
The more complete available review of parsing I know of is Parsing
Techniques - A Practical Guide of Grune and Jacobs can perhaps help
you. The first edition is out of print but available here in PDF:
http://www.cs.vu.nl/~dick/PTAPG.html
There is a second edition in preparation but AFAIK it is not available yet.
Yours,
--
Jean-Marc
| |
| Torben Ęgidius Mogensen 2007-09-10, 7:13 pm |
| Joachim Durchholz <jo@durchholz.org> writes:
> I need to read up on ways to extend operator-precedence parsing to
> "circumfix" operators such as (...), [...], if...then...else... etc.
I have heard "outfix" being used about these.
> My knowledge of operator-precedence parsing is mostly at the Dragon
> Book level. Any solid overview that covers the design options and
> lists their trade-offs would be helpful.
A few pointers that might be good places to start:
http://en.wikipedia.org/wiki/Operator-precedence_parser
http://www.epaperpress.com/oper/index.html
Torben
| |
| Jeff Kenton 2007-09-13, 4:21 am |
| 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.
jeff
| |
| Joachim Durchholz 2007-09-13, 7:12 pm |
| Jeff Kenton schrieb:
> 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.
That's indeed what I'm after.
> Otherwise, I'd use a recursive descent parser for most of the
> language and switch to operator precedence parsing just for expressions.
The goal is to have an all-operators language. Well, just syntactically,
so it's really going to be an all-operator-precedence language :-)
Regards,
Jo
[You know, if we want BLISS, we know where to find it. -John]
|
|
|
|
|