|
home—lectures—recipe—exams—hws—D2L—breeze (snow day; distance)
Due Oct.17 (Mon) 15:00
Your name and the assignment-number must be in a comment at the start of the file, along with a link to this assignment page.
I encourage you to actually put all the nonterminals in upper-case (or at least first-letter-upcased), just to make it easier to tell terminals from non-.
<JsFunc> → function <JsIdent>( <JsIdents> ) { <JsBody> } |
For the grammar rules, write them as in class: in basic BNF
using “→” (and “
(2pts)
As we consider how to define
Working towards a solution, the programmer MC Carthy comes up with the following attempt for a nonterminal that generates comma-separated lists of “x”s (albeit still ending in a semicolon, unlike our part (c) next):
<XS> → ; | x; | x, <XS> |
Prove that this grammar is not correct, by giving a derivation of some string which is not a valid comma-separated list (ending in a semicolon).
(6pts) Generating a grammar
Give a grammar for Java's boolean expressions.
(That is: a grammar describing exactly what you are allowed to put
inside the parentheses of a Java
For this problem, assume that you already have grammar rules for
a Java numeric expression
(“
Using your grammar, give a parse tree (not a derivation) for:
In the tree, for children of
1 I encourage you to notate, to the right of each step, the exact rule-number used for that step (numbering the grammar rules 1,2,3a,3b, etc.). ↩
2 The best answer is the shortest: if you have a simple example that uncovers the grammar's flaw, that is better than a long example doing so. ↩
3 You can turn in your printout + your drawing, or if If you really want just one file to turn in, you can photo and then insert it into DrRacket. ↩
home—lectures—recipe—exams—hws—D2L—breeze (snow day; distance)
©2016, Ian Barland, Radford University Last modified 2016.Oct.16 (Sun) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |