procedure → INT WAIN LPAREN dcl COMMA dcl RPAREN LBRACE dcls statements RETURN expr SEMI RBRACE type → INT type → INT STAR dcls → dcls → dcls dcl BECOMES NUM SEMI dcls → dcls dcl BECOMES NULL SEMI dcl → type ID statements → statements → statements statement statement → lvalue BECOMES expr SEMI statement → IF LPAREN test RPAREN LBRACE statements RBRACE ELSE LBRACE statements RBRACE statement → WHILE LPAREN test RPAREN LBRACE statements RBRACE statement → PRINTLN LPAREN expr RPAREN SEMI statement → DELETE LBRACK RBRACK expr SEMI test → expr EQ expr test → expr NE expr test → expr LT expr test → expr LE expr test → expr GE expr test → expr GT expr expr → term expr → expr PLUS term expr → expr MINUS term term → factor term → term STAR factor term → term SLASH factor term → term PCT factor factor → ID factor → NUM factor → NULL factor → LPAREN expr RPAREN factor → AMP lvalue factor → STAR factor factor → NEW INT LBRACK expr RBRACK lvalue → ID lvalue → STAR factor lvalue → LPAREN lvalue RPAREN
Instances of the tokens ID, NUM, NULL and the non-terminals factor, term, expr, and lvalue have a type, which is either int or int*. Types must satisfy the following rules:
int wain(int, int);
void println(int);
// === Insert WLPP Program Here ===
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv) {
int a,b,c;
printf("Enter first integer: ");
scanf("%d", &a);
printf("Enter second integer: ");
scanf("%d", &b);
c = wain(a,b);
printf("wain returned %d\n", c);
return 0;
}
void println(int x){
printf("%d\n",x);
}
int wain(int*, int);
void println(int);
// === Insert WLPP Program Here ===
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv) {
int l, c;
int* a;
printf("Enter length of array: ");
scanf("%d", &l);
a = (int*) malloc(l*sizeof(int));
for(int i = 0; i < l; i++) {
printf("Enter value of array element %d: ", i);
scanf("%d", a+i);
}
c = wain(a,l);
printf("wain returned %d\n", c);
return 0;
}
void println(int x){
printf("%d\n",x);
}