Re: fully parenthesized expression?

"Mr.E" <>
8 Mar 2007 09:40:28 -0500

          From comp.compilers

Related articles
fully parenthesized expression? (Mr.E) (2007-03-03)
Re: fully parenthesized expression? (Dmitry A. Kazakov) (2007-03-05)
Re: fully parenthesized expression? (Mr.E) (2007-03-08)
Re: fully parenthesized expression? (Dmitry A. Kazakov) (2007-03-08)
Re: fully parenthesized expression? (Mr.E) (2007-03-10)
| List of all articles for this month |

From: "Mr.E" <>
Newsgroups: comp.compilers
Date: 8 Mar 2007 09:40:28 -0500
Organization: Compilers Central
References: 07-03-01507-03-022
Keywords: parse, question
Posted-Date: 08 Mar 2007 09:40:28 EST

> 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.

Unfortunately, I'm not comprehending. I dont know if its similar to
an idea I played with unsuccessfully of 'marking' the resulting stack
element unusable after a reduction. As for example in a multiplcation

value[valTop-1] = value[valTop-1] * value[valTop];
usableValue[VTop - 1] = FALSE;

Where value is the stack for values and usableValue is the stack
indicating if a value is usable for dispaly purposes. As a value is
entered when a new token is read into the stack usableValue[x] it is
marked TRUE to indicate it is usable for display purposes.

If neither value has been used then you would display

' ( valueLHS operator valueRHS ) '

If the left hand side is not usable for display purposes then only the
operator and the right hand side are added to the display.

' operator ValueRHS ) '

I dont know if it was my implementation or just luck but sometimes it
would work and other times it would be really off.

I also wondered if I could write a binary expression tree from the
input but havent been able to figure out how to move the expressions
around once I've determined they need to be shifted.

Open to ideas.


Post a followup to this message

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