Question: procedure Stmt( ) if ts.peek( ) = id then call match( ts, id ) call match( ts, assign ) call Val( ) call Expr( )
procedure Stmt( )
if ts.peek( ) = id
then
call match( ts, id )
call match( ts, assign )
call Val( ) call Expr( )
else if ts.peek( ) = print
then
call match( ts, print )
call match( ts, id )
else
call error( )
end
Figure 2.7: Recursive-descent parsing procedure for Stmt. The variable ts is an input stream of tokens.
Question
The recursive-descent code shown in Figure2.7 contains redundant tests for the presence of some terminal symbols. How would you decided which ones are redundant?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
