Re: fully parenthesized expression?

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
5 Mar 2007 03:32:44 -0500

          From comp.compilers

Related articles
fully parenthesized expression? mr.waverlye@verizon.net (Mr.E) (2007-03-03)
Re: fully parenthesized expression? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2007-03-05)
Re: fully parenthesized expression? mr.waverlye@verizon.net (Mr.E) (2007-03-08)
Re: fully parenthesized expression? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2007-03-08)
Re: fully parenthesized expression? mr.waverlye@verizon.net (Mr.E) (2007-03-10)
| List of all articles for this month |

From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Newsgroups: comp.compilers
Date: 5 Mar 2007 03:32:44 -0500
Organization: cbb software GmbH
References: 07-03-015
Keywords: parse
Posted-Date: 05 Mar 2007 03:32:44 EST

On 3 Mar 2007 23:31:39 -0500, Mr.E wrote:


> After a good deal of research and effort I have a working operator
> precedence parser. For debugging purposes I would like to output a
> fully parenthesized representation of the original expression.
> Unfortunately, I'm not having success in displaying this. Before I
> reduce I print out what is on the stack ( value 'operator' value ) but
> in most cases the left hand side of the stack contains the result of
> the previous operation I no longer have the original value.


> May I ask if someone would suggest a way to display the operation as
> it is performed.


You need an output queue with both ends accessible rather than a FIFO
output stream ["print"]. But the technique I am using is different. I add
the source location range to all values on the operation and the argument
stacks. The expression terms get the location range of the corresponding
literal / identifier. So do the operations. When a new value is computed
its location range is evaluated as the least range containing the ranges of
the operation and operands generating the value. The ranges can be then
used for error messages generation and in your case to indicate parsing /
evaluation progress and operands association in the source.


--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



Post a followup to this message

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