120 views

Can anyone tell how to solve the below question?

| 120 views
0

@Shaik Masthan

plz tell me r u getting $a*a+a$??

@pranay562

What are we doing, is it for expression

$E\rightarrow E\left \{ print "+" \right \}+T$

or

Is it for

$E\rightarrow E+T\left \{ print "+" \right \}$

I know SDD do postfix evaluation, but is it applicable here?

0

@pranay562

How much I got top-down parser is a subset of bottom-up parser.

So, SDD for both will be same and it will be in semantic analysis phase of any compiler.

Will be same for top-down and bottom-up compiler.

Plz. correct me if anything wrong in these words.

0

Which one is correct between these two

https://gateoverflow.in/96963/compilers

one must be incorrect.

One printing from bottom to top and another top to bottom.

Though I havenot got any resource which is printing bottom to top.

So, I think @Mk Utkarsh ans is correct.

right?

It will just printed when parser get it. right na??

0

Ans will be C)

Rightmost derivation

$E\rightarrow E+T$           (+ printed)

$E\rightarrow E+T*F$      (* printed)

$E\rightarrow E+T*a$       (a printed)

$E\rightarrow E+F*a$

$E\rightarrow E+a*a$      (a printed)

$E\rightarrow F+a*a$

$E\rightarrow a+a*a$       (a printed)

Now, do bottom-up parsing and find "handle"

$a+a*a$

$F+a*a$         Handle-$F$

$E+a*a$         Handle-$E$

$E+F*a$         Handle-$F$

$E+T*a$         Handle-$T$

$E+T*F$         Handle-$F$

$E+T$                Handle-$T$

$E$                        Handle-$E$

by (558 points)
selected
0

https://gateoverflow.in/96963/compilers

And there pdf link is given in which mention that :

General rule: The actions are viewed as "dummy" terminals embedded in the parse tree. They are executed in the order of a preorder traversal of the tree. Thus, the result of the SDT is the same whether parsing is top-down, bottom-up, or something else.

What does it relly means????

0
@srestha I am not  able to understand the handle method can you explain it in a more elaborate way??

Thank you
+1

@arya_stark

In ur given link, isnot the grammar printing from last?

Check it again

@Pratyush Priyam Kuan

It is just reverse of rightmost derivation method. right?

+2

@arya_stark

See it

0
Sorry
But i still in confusion which is correct and which is not!!
0

@arya_stark

What I got still now, this SDT should be L-attributed, because semantic rules are in middle. So, cannot be evaluated in bottom-up parser. It can evaluated in top-down parser. So, nothing but DFS search is required.

right??