
Compiler Construction – SMD163
Homework assignment 2
1. Manually identify the tokens (and associated attributes) in the
following
Java program:
int max(int i1, int i2) { // Compute some sick kind of max.
if ((i1 < i2) && (i1 < 20))
return i1;
i2 += i1;
return i1;
}
2. Give regular expressions to describe the following:
- Strings over a,b,c with
an odd number of a’s
- Strings over a,b,c
where the first a precedes
the first b (if any), and the first
b precedes the first c (if any).
- Binary numbers that are multiples of 4.
- Octal numbers that are multiples of 64.
- Decimal numbers that are multiples of 4 (without leading zeros)
- Strings over a,b,c that
contain the three characters abc
in sequence
3. What languages do the regular expressions a?*, a**, a+* represent?
- Are any of these expressions erroneous?
- Would you say that any of these regular expressions are ambiguous?
Report via email to
.
Subject line: SMD163 - 2.
Deadline is Jan 30, 14.45.
Homework assignments are carried out individually.
Oral discussion is good, copying
files is not!