list : expr | list COMMA expr ; expr : CONST | IDENT | expr PLUS expr | expr MINUS expr ;What are the terminal symbols:
4. Let G be the grammar
S -> aB | bAFor the string aaabbabbba, find a right-most derivation, and draw its parse tree.
A -> a | aS | bAA
B -> b | bS | aBB
5. Consider the grammar
S -> AAList the strings of terminals that can be derived by four or fewer steps.
A -> AAA | a | bA | Ab
6. Consider the alphabet {a, b, (, ), |, *, ε}. Using this alphabet, construct a context free grammar for regular expressions over {a, b}.
7. Eliminate the left recursion from the following grammar fragment.
S -> TypeDeclarationsOpt
TypeDeclarationsOpt-> TypeDeclarations | ε
TypeDeclarations-> TypeDeclaration | TypeDeclarations TypeDeclaration
TypeDeclaration-> basetype ident semicolon
int f(int y) { int x; char *c, s[10]; x = 5; c = s; c[10] = '\0'; c = "Hello"; }
struct tlist { struct tok *t; struct tlist *next; } ; /* append a COPY of t to the end of l */ int append(struct tok *t, struct tlist *l) { struct tlist *lp; struct tok *p; if (l == NULL) return -1; if (lp = malloc(sizeof(struct tlist)) == NULL) return -2; lp->next = NULL; if ((lp->t = malloc(sizeof(struct tok))) == NULL) { free(lp); return -3; } *(lp->t) = *t; while(l->next != NULL) l = l->next; l->next = lp; return 0; }