Re: fully parenthesized expression?

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
8 Mar 2007 19:52:49 -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: 8 Mar 2007 19:52:49 -0500
Organization: cbb software GmbH
References: 07-03-01507-03-022 07-03-026
Keywords: parse
Posted-Date: 08 Mar 2007 19:52:49 EST

On 8 Mar 2007 09:40:28 -0500, Mr.E wrote:


> [snip]
>> 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;


The variant with queue (pseudo-code):


Stack >> Right;
Stack >> Left;
Stack << Left * Right;
'(' >> Qutput; // The left side of the output queue accessed
Output << '*';
Output << Right;
Output << ')';


Once you finished, you can print Output.


The variant with source locations:


Stack >> Right;
Stack >> Left;
Stack <<
      Operand
      ( Left.Value * Right.Value,
            Left.Location + Right.Location + Location_of_Multiply
      );


At this point you can show the operand's associations in the source code
window using for example colored boxes drawn around them. The operation
sign would have the color of the boxes around the operands. The result
could look like this:
._____________. .___.
|.___. .___.| | |
|| 2 | * | 3 || + | 4 |
||___| |___|| | |
|_____________| |___|


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