













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














2
4
YACC Parser Generator
5
YACC Parser Generator
7
Flex input file for a calculator
%{
#include "y.tab.h"
%}
digit [0-9]
ws [ \t\n]+
%%
{ws} ;
{digit}+ {return NUMBER;}
"+" {return PLUS;}
"*" {return TIMES;}
"/" {return DIVIDE;}
"–" {return MINUS;}
%%
8
YACC
expr.y
expr.l
y.tab.c
lex.yy.c lex
CC
expr.exe y.tab.h
10
void fie(int a, int b)
{ .... }
void fee() {
int f[3],g[0],h,i,j,k;
char* p;
fie(h, i, “ab”);
k = f*i+j;
h = g[17];
p = 10;
}
what is wrong with
this program?
11
void fie(int a, int b)
{ .... }
void fee() {
int f[3],g[1],h,i,j,k;
char* p;
fie(h, i, “ab”);
k = f*i+j;
h = g[17];
p = 10;
}
dimension of g is 1,
index is 17
13
void fie(int a, int b)
{ .... }
void fee() {
int f[3],g[1],h,i,j,k;
char* p;
fie(h, i, “ab”);
k = f*i+j;
h = g[17];
p = 10;
}
f is an array;
used without
index
14
void fie(int a, int b)
{ .... }
void fee() {
int f[3],g[1],h,i,j,k;
char* p;
fie(h, i, “ab”);
k = f*i+j;
h = g[17];
p = 10;
}
10 is not a
character string
16
Is “x” a scaler, an array or a
function?
Is “x” declared before it is
used?
Is the expression “x*y+z”
type-consistent?
17
Is “x” a scaler, an array or a
function?
Is “x” declared before it is
used?
Is the expression “x*y+z”
type-consistent?
19
In “a[i,j,k]” does a have
three dimensions?
Does “*p” reference the
result of “new”?
Do “p” and “q” refer to the
same memory location?
20
In “a[i,j,k]” does a have
three dimensions?
Does “*p” reference the
result of “new”?
Do “p” and “q” refer to the
same memory location?