|
Due Oct.15 (Mon) 15:00, hardcopy and D2L.
Submit a single pdf file named hw05.pdf:
I suggest using a text-editor like Word (or LibreOffice or DrRacket or similar): The derivations are best written in a text-editor where you can copy/paste one line and replace a single non-terminal to create the next line. But for parse-trees, I recommend drawing them freehand.
Your hardcopy should include your answers, and your (presumably-hand-drawn) trees. Including images is optional for the pdf; I will use your hardcopy to grade the trees.
If you do want to incorporate your images (in the single pdf), you can of course do so via Word/LibreOffice/etc.; you may also do so via DrRacket's Insert » Insert Image…, and then printing to pdf.
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 derivation2 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
This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |