Design a lexical analyzer using transition diagram that recognizes:
Show the transition diagram and write pseudocode for the nextToken() function.
a) Type checking: Static vs Dynamic type checking with examples b) Synthesized vs Inherited attributes with expression evaluation example
Identify loop invariant code that can be moved out of the loop, if any.
Apply these optimizations to the following assembly code:
MOV R0, a
MOV b, R0
MOV R0, b
ADD R0, R0, #0
MUL R0, R0, #2
MOV R1, #10
ADD R1, R1, #5
MOV R2, #0
ADD R2, R2, R1
Show the activation tree and activation record contents for the following code at the point when factorial(1) is executing:
int factorial(int n) {
if (n <= 1)
return 1;
return n * factorial(n-1);
}
int main() {
int x = factorial(3);
Which is most efficient and why?
Show hash table implementation for storing the following identifiers using hash function h(x) = (sum of ASCII values) mod 7:
Identifiers: {sum, count, avg, total, temp}
Use chaining for collision resolution.
E → E + T | T
T → T * F | F
F → (E) | idBuild the complete operator-precedence table. Parse the string id + id * id using this table showing all stack operations.
I₀ = {[S’ → •S, $]}
Grammar:
S → AB
A → aA | b
B → c
Then compute GOTO(I₀, a) showing all steps.
Share this link via
Or copy link