Subject: Re: Parsing a List with infix-operators
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 31 Jul 2004 08:48:05 -0500
Newsgroups: comp.lang.lisp
Message-ID: <suydneCAQ6KIPpbcRVn-uQ@speakeasy.net>
Stefan Ram <ram@zedat.fu-berlin.de> wrote:
+---------------
|   Given a list with infix notation:
| 
| ( 1 + 2 * 3 )
| 
|   There are several methods how to convert such a list to
|   Cambridge notation with the result:
| 
| ( add 1 ( multiply 2 3 ))
| 
|   Beside all of the classical ways to parse a sequence of tokens
|   (like a recursively descending parser), I think about of going
|   through the list several times with one loop for each level of priority.
+---------------

It is *MUCH* simpler to use a simple-operator-precedence parser
[see any basic text on parsing], and you can do it in only one pass
through the expression, too, no matter how many levels of operator
priority you have.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607