Recursive Decent Parsing:Functions to parse the Toy Grammar III
Here is the last of the four functions of the Toy Grammar. This grammar rule has several alternatives. A switch() statement selects the right alternative to parse based on what the current look ahead token is.
Remember, no actions are yet added to these functions. All they do is recognize the input and move on; they dont do anything with it yet.
<> --> ID | CONST | ( <> )
scanner(); /* get next lookahead token */
scanner(); /* get next lookahead token */
scanner(); /* get next lookahead token */
if( tokentype != RIGHTPAREN )
scanner(); /* get next lookahead token */
error(Missing ID, CONST, or ();