Re: fully parenthesized expression?
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: 8 Mar 2007 19:52:49 -0500
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
.
- Follow-Ups:
- Re: fully parenthesized expression?
- From: Mr.E
- Re: fully parenthesized expression?
- References:
- fully parenthesized expression?
- From: Mr.E
- Re: fully parenthesized expression?
- From: Dmitry A. Kazakov
- Re: fully parenthesized expression?
- From: Mr.E
- fully parenthesized expression?
- Prev by Date: Re: RegExp to match against RegExp's
- Next by Date: Block reording.
- Previous by thread: Re: fully parenthesized expression?
- Next by thread: Re: fully parenthesized expression?
- Index(es):
Relevant Pages
|
|