Question & Answer: Consider the following grammar for a declaration list:…..

Consider the following grammar for a declaration list:

decl_list → decl ; decl_list | ε

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Consider the following grammar for a declaration list:…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

decl → specifier type name_list

specifier → const | static | ε

type → double | int

name_list → name | name , name_list

name → id args

args → ( decl_list ) | ε

(a) (4 pts) Indicate whether each of the following strings belongs to the language described by the grammar. int a (int b); int c (int d (int e;);); double f, g (static int h;); static int i; const double j;

(b) (7 pts) Show a leftmost derivation of the string static int f(); under this grammar.

(c) (10 pts) Rewrite the grammar so that arguments are separated by commas (similar to the function arguments in C). For instance, each of the following should be a valid string under the new grammar: int f (); int f (double x); int f (double x, int y);

Expert Answer

 

 

Question & Answer: Consider the following grammar for a declaration list:..... 1

Question & Answer: Consider the following grammar for a declaration list:..... 2

Question & Answer: Consider the following grammar for a declaration list:..... 3

Question & Answer: Consider the following grammar for a declaration list:..... 4

Question & Answer: Consider the following grammar for a declaration list:..... 5

Still stressed from student homework?
Get quality assistance from academic writers!