Using the syntax of C write a recursivedescent subprogram na

Using the syntax of C, write a recursive-descent subprogram named initializer that corresponds to the following rules (taken from the C99 standard): initializer: assignment-expression {initializer-list} {initializer-list, } Note that {and} are terminals, not metasymbols. Assume that recursive-descent subprograms named assignment-expression and initializer-list already exist.

Solution

<initializer> -> \"{\" <designator> { <designator> } = <expression> \"}\"

From my understanding from reading my book..for this code:
<expr> -> <term> { ( + | - ) <term> } the recursive descent subprogram would be

void expr ( ) {

/* Parse the first term */
  
term ( ) ;

/* As long the next token is + or -, call lex to get the next token, and parse the next

term */

while (nextToken == PLUS_CODE || nextToken == MINUS_CODE) {

lex ( );
term ( );
}
}

So, I want to know how to do for the code :
<initializer> -> \"{\" <designator> { <designator> } = <expression> \"}\"

 Using the syntax of C, write a recursive-descent subprogram named initializer that corresponds to the following rules (taken from the C99 standard): initialize

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site