Using the syntax of C, write a recursive descent subprogram that corresponds to
ID: 3807096 • Letter: U
Question
Using the syntax of C, write a recursive descent subprogram that corresponds to the following EBNF production
<local_variable_declaration_statement>
[ final ] <type> <variable_declarator> { , <variable_declarator> } ;
{, }, [, and ] are metasymbols. Assume that the token codes for final, the comma, and
the semicolon are FINAL_CODE, COMMA_CODE, and SEMICOLON_CODE, respectively. .Also assume that recursive-descent subprograms named type and variable_declarator already exist.
Explanation / Answer
Below is the sample code
void expression ( ) {
/* Parse the first Next_Term */
Next_Term ( ) ;
/* As long the next term is + or -, call lexical to get the next token, and parse the next
Next_Term */
while (nextTerm == PLUS_CODE || nextTerm == MINUS_CODE) {
lexical ( );
Next_Term ( );
}
}
Please let us know if you need anything else. Thanks!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.