-
Notifications
You must be signed in to change notification settings - Fork 14
Semantic Analyzer
Vishal Mittal edited this page Mar 9, 2020
·
4 revisions
- TRUE PLUS FALSE -> accepted by Syntax Analyzer, so resolve here
- Resolve Arithmetic and Boolean Expr ambiguity
- Is x scalar, an array, or a function?
- Is x declared before it is used?
- Is x defined before it is used?
- Are any names declared but not used?
- Which declaration of x is being referenced?
- Is an expression type-consistent?
- What is the meaning of res= a+b*c? When a is integer, b and c are of float type.
- Does the dimension of a reference match the declaration?
- Where can x be stored? (heap, stack, ...)
- Does *p reference the result of a malloc()?
- Is an array reference in bounds?
- Does function foo produce a constant value?
- Consider the following program:
- fie(a,b,c,d)
- int a, b, c, d;
- { … }
- fee()
- {
- int f[3], g[10], h, i, j, k;
- char *p;
- call fie(h, i, “ab”, j, k);
- k = f * i + j;
- h = g[17];
- printf(“<%s,%s>.\n”,p,q);
- p = 10 + ‘c’;
- If( i = i+4)
- }
- Issues:
- declared g[10], used g[17]
- wrong number of args to fie()
- “ab” is not an int
- wrong dimension on use of f
- undeclared variable q
- 10 is not a character string