Starting from:

$30

Assignment #1 What does syntax describe?

Assignment #1 (10 points)


1. What does syntax describe? Give three examples of syntax errors (three different kinds of syntax errors – do not use the exact same examples discussed in the lectures). Name three different ways of defining syntax.

2. What does semantics describe? Give three examples of semantics errors (three different kinds of semantics errors – do not use the exact same examples discussed in the lectures). Name two different ways of defining semantics.

3. Use EBNF or BNF to describe the syntax of Java if statements, no need to further define other statements or Boolean expressions.

4. Python uses indention in its program structures. How do you define the syntax of a language construct that uses indention? Give an example to describe. (Note: do online search to find the complete BNF grammar rules for Python.)

5. Use pseudo code such as
a = b op c (note: op could be any common operators such as +, -, .., <, , …)
if a < b goto L
goto L (note: goto L means “jump-to L” or “j L”.)
to describe the semantics of the following Java-like while statement
while (a < b ) {
s = s + b * c;
a = a + 1;
}

6. (optional) Repeat problem 5 but now we change while (a < b) to while (a < b && b < c) { … }

Note: optional problem could be used to substitute any above problem, for example, if you did problem 4 wrong but problem 6 correctly you could use problem 6 to fulfill the points requirement of problem 4. However, there won’t be any bonus points beyond 10 points for this assignment (i.e. maximum points is 10.)

More products