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. 25 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 (e.g., '{' and '}') and operators (e.g., '+' 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.
X 2b x1y2 a_1
expr abstraction at the root). If invalid, briefly describe what aspect violates the rules.
-4 (-4) (1 + -4) x x*10
(x * 10) (a & !b) (a & (!b)) (3 > 2 > 1) ((2 < 3) | true)
if abstraction at the root). If invalid, briefly describe what aspect violates the rules.
if (x = y) then if true then if (m > n) then if (grade > 90) then
print "eq" else endif print 0 x gets "A"
endif else if (m = n) then elseif (grade > 80) then
print 1 x gets "B"
else endif
print 2
endif
assign) that is as short as
possible, in terms of number of tokens. Note that keywords (such as gets) 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.sub) that is as short as
possible, in terms of number of tokens. You do not need to provide a parse tree.call) that is as short as
possible, in terms of number of tokens. You do not need to provide a parse tree.