![]() |
![]() |
|
home—lectures—exams—hws—breeze (snow day)
Due: due Oct.17 (Wed) 18:00.
Use a computer (text file) for your derivations,
since each step involves repeating (most of) the previous step.
However, you can draw your tree freehand.
<JsFunc> → function <JsIdent>( <JsIdents> ) { <JsBody> } |
(2pts)
The book's example for
The programmer MC Carthy uses this feature, and comes up with the following attempt for a nonterminal that generates comma-seperated lists of “x”s:
<XS> → ε | x | x, <XS> |
Prove that this grammar is not correct, by giving a derivation2 of a string which is not a comma-separated list.
Give your grammar rules in basic BNF
and → (and
(6pts) Chpt.3, #5 [write a BNF for boolean expressions in 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
Note that there is arguably a slight bug in the book's presentation;
if they are using angle-brackets around the nonterminal
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. ↩
home—lectures—exams—hws—breeze (snow day)
©2012, Ian Barland, Radford University Last modified 2012.Oct.18 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |
![]() |