Question: LL ( 1 ) Grammar program > :: = def funcname > arguments > : ? block > EOF funcname > :: = f |

LL(1) Grammar
program >::= def funcname > arguments >:?
block > EOF
funcname >::=f|g
arguments variable > morevars >
morevars >::=, variable > morevars >|lon
block >::= stmtlist >
stmtlist >::???=t stmt > morestmts >
morestmts >::??
= stmtlist >|lon
stmt >::= assign >| ifstmt >| returnstmt >
assign >::= variable expr >
condition >::= variable > expr >
ifstmt >::= if condition > : >::=>>::=>+>>::=>|>>::=a|b|c>::=0|1|2>
returnstmt >::= return variable >
expr >::= term >+ term >
term >::= variable >| digit >
variable >::=a|b|c
digit >::=0|1|2
represents the "new line" terminal. ?t represents the "tab" terminal.
(a) Show that the grammar above isLL(1). Use a formal argument based
on the definition of the LL(1) grammar.
(b) Show the LL(1) parse table.
(c) Write a recursive descent parser in pseudo-code. You may assume that
the nexttoken() function is already implemented for reading the next
token in the remaining input string, and you can directly use itin your
pseudocode.??
>??t else : >
returnstmt >::= return variable >
expr >::= term >+ term >
term >::= variable >| digit >
variable >::=a|b|c
digit >::=0|1|2
represents the "new line" terminal. ?t represents the "tab" terminal.
(a) Show that the grammar above isLL(1). Use a formal argument based
on the definition of the LL(1) grammar.
(b) Show the LL(1) parse table.
(c) Write a recursive descent parser in pseudo-code. You may assume that
the nexttoken() function is already implemented for reading the next
token in the remaining input string, and you can directly use itin your
 LL(1) Grammar program >::= def funcname > arguments >:? block >

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!