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. 24 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, number, character or string. Delimiters, i.e. '(', ')', '{', '}', '[', and ']', do not require spaces to separate them from other tokens, but all others do.
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 4b a1BC X_1
number abstraction at the root). If invalid, briefly describe what aspect violates the rules.
44 -44 0.5 .5 5.
-.2 --9 E4 -3e2 -3.1e2.5
expr abstraction at the root). If invalid, briefly describe what aspect violates the rules.
x (x) (-x) (x + 1) (+ x 1) (- x 1)
if abstraction at the root). If invalid, briefly describe what aspect violates the rules.
if (== x y) { if true { } if (> m n) { if (avg >= 80) {
print "eq" else { } print 0 if (avg >= 90)
} } else { print "A"
print 1 else
} print "B"
} else {
print "F"
}
assign) that is as short as
possible, in terms of number of tokens. Note that keywords (such as print) and operators (such as ==) are indivisible and thus count as a single token. You do not need to provide a parse tree.while) that is as short as
possible, in terms of number of tokens. You do not need to provide a parse tree.func) that is as short as
possible, in terms of number of tokens. You do not need to provide a parse tree.