|Building Abstract Syntax Trees from LL(1) Grammars firstname.lastname@example.org (Bart T.) (2002-08-14)|
|Re: Building Abstract Syntax Trees from LL(1) Grammars email@example.com (Capitaine Caverne) (2002-08-23)|
|Re: Building Abstract Syntax Trees from LL(1) Grammars firstname.lastname@example.org (2002-08-23)|
|From:||"Capitaine Caverne" <email@example.com>|
|Date:||23 Aug 2002 11:03:08 -0400|
|Organization:||Guest of ProXad - France|
|Posted-Date:||23 Aug 2002 11:03:08 EDT|
"Bart T." <firstname.lastname@example.org> a écrit news:email@example.com:
> (- (+ 9 5) 2)
> (+ 9 (- 5 2))
> However, it isn't possible to generate the operators prior to the
> operands in my grammar. :( At least I can't think of a way. There must
> be a way, though...
Hello, I'm certainly the last person to listen in this newsgroup as I'm a
complete newbie... However in my try to implement a stack based machine
compiler I have the same problem : I can't handle operators and operands
in a way I would like (was not a problem when I implemented my own poor
parser some years ago).
The solution I've found is to use two stacks : an operand stack and an
Thus instead of generating (generated code is not in the source order)
PUSH VAL 3
PUSH VAL 2
I do :
PUSH VAL 3 (generated code is in source order)
PUSH VAL 2
PUSH VAL 9
This is less efficient but it works... At least it seems ;-)
Not sure it answer your question, once again I'm a newbie...
Return to the
Search the comp.compilers archives again.