next up previous
Next: Straightforward Generation Up: No Title Previous: Exercise

From a Regular Language to Program Code

Expr Prog(Expr)
"x" if (ch == 'x') nextCh(); else error();
(E) Prog(E)
[E] if (ch in first(E)) { Prog(E) }
{E} while (ch in first(E)) { Prog(E) }
E F Prog(E) Prog(F)
E | F if (ch in first(E)) { Prog(E) } else { Prog(F) }

first(E) is the set of terminals, E can start with.

Q: What is first(BinNumber)?

If we use multiple rules, each rule gives one procedure.



Christoph Zenger
3/23/2000