These are sample questions. I will add more as the week progresses.
- What is the character set of C? What is the character set of Java? Which
part of the compiler will be influenced by these?
- Write a regular expression whose language is all strings over a,b and
whose length is a multiple of 3.
- Define Java comments using Lex.
- A gloating point number is one with at least a digit in the whole part
and at least a digit in the fractional part. Define a regular expression for
it.
- What is the edit distance between strings aabbbaaa abbaaaab?
- Write down FIRST and FOLLOW of S--> a S b | ab
- Is the above grammar LR(0)? Is it LR(k) for any k?
- S --> a S | epsilon. Is this grammar LR(0)? Is it LR(k) for any k?
- Explain briefly how the LL(1) parser works?
- Remove immediate left recursions from A --> A b | c A | B d | e
- What is the language produced by the grammar S --> a S a | b S b | c?
- The grammar for regular expressions is: 1) E --> E | T 2) E--> T
3) T --> T F 4) T --> F 5) F --> ( E ) 6) F --> i 7) F --> F *
Construct the SLR table
- Construct the SLR table 1) S --> E = E 2) S --> i 3) E --> E + i 4) E --> i. Note where the reduce/reduce action conflict occurs.
- Write a syntax directed translation scheme to count the nesting of
if statements.
- Repeat the above problem for while statements.
- What is the type of int a[][];
- What is the type of int foo(int a, Double b, int[] c);
- Unify the expressions f(g(a,b),c) and f(e,g(a,b))
- What is the type of the following method:
fun sum x x = f x end;
- Find the basic blocks of x = 0; while (x < 10) { x=x+1;}
- Generate byte code (assembler format is fine) for the following block:
int sum, a[]; a= new int(10);sum = 0; for(i=0;i<10;i++) sum = sum+a[i];
- Generate bytecode for x=90; if (a < b) x=x+y; else x=x-y;
you can assume all the variables are integers.