In the first half of the semester, you will be developing an interpreter for a simple scripting language named SILLY (Simple, Interpreted, Limited Language for You). The EBNF grammar rules for SILLY v. 23 are as follows:
Recall that |
denotes alternatives within a rule, [ ]
denotes an optional (0 or 1) element, and { }
denotes a repetitive (0 or arbitrarily many) element. There is no whitespace (i.e., spaces, tabs or new lines) between the characters in an identifier, integer, or string. Otherwise, whitespace may appear between tokens but is not required.
Answer the following questions about the syntax of SILLY based on the above grammar rules.
id
abstraction at the root). If invalid, briefly describe what aspect violates the rules.
Q abc 4b a1b23 123 X_1
expr
abstraction at the root). If invalid, briefly describe what aspect violates the rules.
4 (4) -4 -x x + 1 (x + 1) flag (not true) (not (true)) (not (not true))
(not true or false) (3 + 4 * 5) (8 / 4 / 2)
print
abstraction at the root). If invalid, briefly describe what aspect violates the rules.
print("foo") print(1+2) print((1+2)) print print() print(1, a, true)
if
abstraction at the root). If invalid, briefly describe what aspect violates the rules.
if (x == y) { if true { if (a > b) { if (avg >= 80) { print("eq") } max = a if (avg >= 90) { } noelse } print("A") else { } max = b else { } print("B") } }
while
) that is as short as
possible, in terms of number of tokens (where keywords such as while
and do
each count as only one token).subdecl
) that is as short as
possible, in terms of number of tokens (where keywords such as sub
and (
each count as only one token).subcall
) that is as short as
possible, in terms of number of tokens (where keywords such as call
and (
each count as only one token).