Modify the use of the stack during the depth-first


Modify the use of the stack during the depth-first traversal in Example 5.26 so that the values on the stack correspond to those kept on the parser stack in Example 5.19.

Example 5.19. Three marker nonterminals L, M. and N are used in Fig. 5.36 to ensure that the value of inherited attribute B.ps appears at a known position in the parser stack while the subtree for B is being reduced. The original attribute grammar appears in Fig. 5.22 and its relevance to text formatting is

explained in ExampJe 5.13.

 

Example 5.26 With the syntax-directed definition of Fig. 5.22. suppose we use separate stacks for the inherited attribute ps and the synthesized attribute ht. We maintain the stacks so that B:ps' is on top of the ps stack just before B is first visited and just after B is last visited. Biht will be on top of the hi stack just after B is visited. With separate stacks we can lake advantage of both the copy rules B I'PS : = Bips and B2.PS ;= B.ps associated with B .... BIB 2. s shown in Fig. 5.48. we do not need to push BI.PS because its value is already on top of the stack as B.ps

Request for Solution File

Ask an Expert for Answer!!
Finance Basics: Modify the use of the stack during the depth-first
Reference No:- TGS01477201

Expected delivery within 24 Hours