Re: yacc parse tree

Sukru Cinar <scinar@ug.bcc.bilkent.edu.tr>
22 Dec 1998 04:45:11 -0500

          From comp.compilers

Related articles
[2 earlier articles]
Re: yacc parse tree mikesw@whiterose.net (1998-12-13)
Re: yacc parse tree bob@werken.com (1998-12-18)
Re: yacc parse tree belinfan@cs.utwente.nl (1998-12-18)
Re: yacc parse tree josh_adams@bmc.com (Josh Adams) (1998-12-19)
Re: yacc parse tree joachim.durchholz@munich.netsurf.de (Joachim Durchholz) (1998-12-19)
Re: yacc parse tree scinar@ug.bcc.bilkent.edu.tr (Sukru Cinar) (1998-12-21)
Re: yacc parse tree scinar@ug.bcc.bilkent.edu.tr (Sukru Cinar) (1998-12-22)
Re: yacc parse tree AMartin@ma.ultranet.com (Alan H. Martin) (1999-01-02)
Re: yacc parse tree scinar@ug.bcc.bilkent.edu.tr (Sukru Cinar) (1999-01-02)
Re: yacc parse tree buzzard@world.std.com (1999-01-02)
| List of all articles for this month |

From: Sukru Cinar <scinar@ug.bcc.bilkent.edu.tr>
Newsgroups: comp.compilers
Date: 22 Dec 1998 04:45:11 -0500
Organization: Bilkent University
References: 98-12-018 98-12-022 98-12-060
Keywords: yacc, parse, comment

> [Seems to me you're just building your own stack parallel to the one
> that yacc already keeps for you. I don't see the advantage of storing
> the tree pointer in a global, other than the final top-level tree since
> yacc doesn't let you return it from yyparse(). -John]


no, it wasn't what I meant. it's like this :


top level


tnode* last;


yyparse() {
..
yyreduce:
{
last = a new node where children are
yyvsp[-1..-yylen[yyn]]
}
..
}


I mean, I don't keep a stack, I keep the root of the tree built so far.
when yyparse() returns, we have the root at the pointer "last". the stack
which yyparse() keeps reduces to size 0 when $accept reduces.
( there's a line yyvsp -= yym after yyreduce: )


****************************************************************************
Sukru Cinar scinar@ug.bcc.bilkent.edu.tr
YetNotGraduate Computer Science Student in Bilkent/Turkey
[I suppose that if for some reason you hate saying $2 you could do that.
But the only place you need to assign to last is in the start rule. -John]


Post a followup to this message

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