Question

Consider the following grammar: (//some alternative rules are listed on separate lines without using symbol |):...

Consider the following grammar: (//some alternative rules are listed on separate lines without using symbol |):

stmt −> assignment

−> subr call

assignment −> id := expr

subr call −> id ( arg list )

expr −> primary expr tail

expr tail −> op expr

−> ε

primary −> id

−> subr call

−> ( expr )

op −> + | - | * | /

arg list −> expr args tail

args tail −> , arg list

−> ε

(a) Construct a parse tree for the input string foo(a,b).

(b) Give a canonical (right-most) derivation of this same string.

(c) Prove that the grammar is not LL(1). (//hint: find an example that LL(1) does not work).

(d) Modify the grammar so that it is LL(1). (//hint: use left factoring)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

)Ubi > foo (a ,b SVb-all bte

6) Kit most derivahion ブrm i d nge-2- ︵伊C) for 65) then First (a) n follow(A): stntid B

Add a comment
Know the answer?
Add Answer to:
Consider the following grammar: (//some alternative rules are listed on separate lines without using symbol |):...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a parser program for cSub using the method of recursive descent. The main program here...

    Write a parser program for cSub using the method of recursive descent. The main program here will effectively be the main program of the compiler as a whole. The input to the program will be a Csub source file, specified on the command line. The program will construct a parse tree for the program, with one interior node for every nonterminal in the derivation of the program, and one leaf node for each of the id, num, and real tokens...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT