The test is open-everything with the sole limitation that you neither solicit nor give help while the exam is in progress.
Many of the questions ask about the language Carlos. We have not covered the language in great detail during lectures, This test, therefore, is measuring (at least in a few problems) how well you can look at a language specification and answer questions about it.
| Problem | You got | Out of |
|---|---|---|
| 1 | 15 | |
| 2 | 15 | |
| 3 | 15 | |
| 4 | 15 | |
| 5 | 15 | |
| 6 | 15 | |
| 7 | 10 | |
| TOTAL | 100 |
x.x = x;
to ever legally appear in a Carlos program? If it can, state what
it means, semantically. If not, state why it is impossible
(technically), hinting at either (1) why allowing it would be stupid
(inconsistent with the language design), or (2) the inexplicable
oversight or stupidity of the language designer for leaving it out.
static private synchronized long woofer(Object... v) {
for (int y : f(x)) {
x = p.data[0] * (2<< 5|- x---c);
}
}
deg color 1 0 0 ccw
90 forward 4 color 0 0 1 [ ccw 90
forward 1.5 ] cw 90 forward 1.5
This program draws the letter T with a red vertical line of size 4 units and topped with a 3 unit blue line. A program is a sequence of instructions. The instructions are:
deg - switch to degree mode
rad - switch to radians mode
ccw θ - turn left (counterclockwise) by angle θ
cw θ - turn right (clockwise) by angle θ
forward n - draw a line by moving forward n units.
backward n - draw a line by moving backward n units.
color r g b - set color (r,g,b), values are floats in the range 0 to 1.
[ - save current state
] - restore previously saved state
Write a macrosyntax in EBNF for this language. Handle the brackets
reasonably, please. State whether your grammar
is LL(1) (meaning "can be parsed top-down with only one
lookahead symbol) or not, and whether it is ambiguous or not.
EBNF generally uses
Suppose I wanted to add a new one:
Show how to write A # B # C using only the conventional EBNF markup.