Question

Given the following grammar, FIRST and FOLLOW sets and LL Parser table, trace the parse of...

  1. Given the following grammar, FIRST and FOLLOW sets and LL Parser table, trace the parse of the string “fd xcor + ycor rt ycor” and draw the parse tree.

FIRST(S) = FIRST(B) = FIRST(D) = { fd, rt }

FIRST(A) = { fd, rt, ε }

FIRST(E) = { xcor, ycor }

FIRST(F) = { +, -, ε }

FOLLOW(S) = { $ }                                      S --> BA

FOLLOW(A) = { $ }                                      A --> BA | ε

FOLLOW(B) = { fd, rt, $ }                            B --> D

FOLLOW(D) = { fd, rt, $ }                            D --> fd E | rt E

FOLLOW(E) = { fd, rt, $, +, - }                     E --> xcor F | ycor F

FOLLOW(F) = { fd, rt, $ }                            F --> + EF | - EF | ε

fd

rt

xcor

ycor

+

-

$

S

BA

BA

A

BA

BA

ε

B

D

D

D

fd E

rt E

E

xcor F

ycor F

F

ε

ε

+ EF

- EF

ε

Stack                                             Input                               Production                  Derivation

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

Tracing The Parse of the String:

Add a comment
Know the answer?
Add Answer to:
Given the following grammar, FIRST and FOLLOW sets and LL Parser table, trace the parse of...
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
  • LL(1) Parser For the grammar: 1. S --> TT 2. T --> aT 3. T -->...

    LL(1) Parser For the grammar: 1. S --> TT 2. T --> aT 3. T --> b Problems Calculate LL(1) parse table Parse string "abab" and construct its parse tree Bonus: Parse string "aabb" and construct its parse tree

  • Please help me with the coding for LL(1)!! The given grammar was: P → PL |...

    Please help me with the coding for LL(1)!! The given grammar was: P → PL | L L → N; | M; | C N → print E M → print "W" W → TW | ε C → if E {P} | if E {P} else {P} E → (EOE) | V (note: this has a variable O) O → + | - | * V → 0 | 1 | 2 | 3 (note: this has a terminal...

  • Question 1. (15 points) Consider the following LL (1) grammar with starting symbol S s→(ST) F...

    Question 1. (15 points) Consider the following LL (1) grammar with starting symbol S s→(ST) F → id F → num a) Compute the First and Follow sets of all non-terminals (5 points) b) Construct the LL (1) parsing table for the grammar (5 points) c) Show step-by-step (content of stack and input string, as well as the production taken) how the following string is parsed: ((20+30 + a)) (5 points)

  • (20 pts) Create an LR(O) parse table for the following grammar. Show all steps (creating closures,...

    (20 pts) Create an LR(O) parse table for the following grammar. Show all steps (creating closures, the DFA, the transition table, and finally the parse table): E->E+T E*T T T->(E) | id Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table you created (id + id) * id Show a rightmost derivation for the string above, and show how the bottom-up parse you completed correctly finds all...

  • 1) Create an LR(0) parse table for the following grammar. Show all steps (creating closures, the...

    1) Create an LR(0) parse table for the following grammar. Show all steps (creating closures, the DFA, the transition table, and finally the parse table): E -> E + T | E * T | T T -> ( E ) | id 2) Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table you created in step 6. Think about how I went through this in class....

  • 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 −> ε...

  • (20 pts) Create an LR(0) parse table for the following grammar. Show all steps (creating closures,...

    (20 pts) Create an LR(0) parse table for the following grammar. Show all steps (creating closures, the DFA, the transition table, and finally the parse table): E -> E + T | E * T | T T -> ( E ) | id (20 pts) Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table you created in step 1. Think about how I went through this...

  • 2A. Check if the given Grammar G is LL (1) by constructing a predictive parse table Clearly specify the different steps...

    2A. Check if the given Grammar G is LL (1) by constructing a predictive parse table Clearly specify the different steps involved during the construction of parse table. A BCg DBCe B BDb E C DCf & D ale Grammar G 4M 2A. Check if the given Grammar G is LL (1) by constructing a predictive parse table Clearly specify the different steps involved during the construction of parse table. A BCg DBCe B BDb E C DCf & D...

  • Show a complete bottom-up parse, including the parse stack contents, input string, and action for the...

    Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table String: (id+id) * id Grammar(language) : E -> E + T |E * T | T T -> (E) | id Parse table: Then show a rightmost derivation for the string above and show how the bottom up parse correctly finds all of the handles. R-reduce S-Shift - Error id S4 S5 S6 S7 Accept R1 R1 R1...

  • Calculate First set, Follow set and LL(1) parsing table. Then judge whether the syntax is or...

    Calculate First set, Follow set and LL(1) parsing table. Then judge whether the syntax is or is not LL(1) grammar.Calculate First set, Follow set and LL(1) parsing table. Then judge whether the syntax is or is not LL(1) grammar. for the given grammar G[S] S→XY X→Ya|ε Y→Zb|Z Z→d|ε

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