Awesome q2a theme
0 votes
137 views

Can anyone tell how to solve the below question?

in Compiler Design by (804 points) | 137 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

@Shaik Masthan @Satbir

Which one is correct between these two

https://gateoverflow.in/293893/madeeasy-subject-compiler-design-syntax-directed-translation

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
0

1 Answer

+2 votes
Best answer

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 (755 points)
selected by
0

Similar Question asked before 

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??

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Jul 2020
  1. Shaik Masthan

    39 Points

  2. hiteshpujari

    9 Points

  3. fazin

    7 Points

  4. srestha

    7 Points

  5. gaurav2697

    6 Points

  6. Venkatesh Akhouri

    6 Points

  7. Meghana518

    6 Points

  8. beastincarnate

    6 Points

  9. athenahermes

    6 Points

  10. bittujash

    6 Points

7,561 questions
1,783 answers
10,869 comments
90,493 users