|Sytnax Tree Construction email@example.com (2003-09-04)|
|Re: Sytnax Tree Construction firstname.lastname@example.org (2003-09-09)|
|Re: Sytnax Tree Construction email@example.com (Yves Deweerdt) (2003-09-09)|
|From:||Yves Deweerdt <firstname.lastname@example.org>|
|Date:||9 Sep 2003 23:05:31 -0400|
|Posted-Date:||09 Sep 2003 23:05:31 EDT|
> I understand the generation of a tree from an expression: 4+2*var:
> / \
> 4 *
> / \
> 2 var
> But for instance, how do you handle the actual language keywords. For
> instance, how would a tree be build for the BASIC code:
> IF x=12
> PRINT "x=12"
> ELSEIF x=14
> PRINT "x=14"
> ELSE CALL function()
> LOOP WHILE x<>20
why do you consider '+' to be an operation taking 2 operands?
and why don't you think of a DO WHILE as an operator too?
it also takes to operands, one being a condition and the other operand
being the statement to execute over and over again until the condition
let's keep it simple:
LOOP WHILE x < 20
would be something like this:
/ \ / \
x + x 20
when you take your expression, you know that when it holds a '+' you
have to take the 2 operands and count them together
now, for the 'DO-WHILE' node, you have to repeat the evaluation of the
left subtree until the right subtree condition evaluates to false...
Return to the
Search the comp.compilers archives again.