Awesome q2a theme
0 votes
120 views

Can anyone tell how to solve the below question?

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

@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

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 (558 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 Dec 2019
  1. Pratyush Priyam Kuan

    158 Points

  2. Vimal Patel

    118 Points

  3. avistein

    65 Points

  4. srestha

    54 Points

  5. Mk Utkarsh

    49 Points

  6. arya_stark

    46 Points

  7. goxul

    39 Points

  8. Sathuri Bharath

    34 Points

  9. vishal burnwal

    31 Points

  10. Shaik Masthan

    26 Points

Monthly Top User and those within 60% of his/her points will get a share of monthly revenue of GO subject to a minimum payout of Rs. 500. Current monthly budget for Top Users is Rs. 75.
2,315 questions
1,294 answers
6,592 comments
89,719 users