a1 - CSE 755, Assignment #1 Due: 7 April '06. 1. (3...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 755, Assignment #1 Due: 7 April ’06. 1. (3 points). Consider the following BNF grammar: h lstring i ::= h s ih s i h s i ::= a | b | c | a h s i | b h s i | c h s i Add appropriate attributes and conditions to the grammar so that only h lstring i s that satisfy the fol- lowing condition are allowed: every occurrence of ‘ a ’ is immediately preceded by a ‘ b and followed by a ‘ c ’. In other words, each occurrence of ‘ a ’ is sandwiched between b and c . (Thus, for example, bacbbcbac ’ is legal, but not ‘ babbcbc ’.) Use synthesized attributes or inherited attributes, or a combi- nation. Do not change the BNF grammar; do not compute the whole string and pass it up to the root – use only simple arithmetic functions in your attribute evaluation rules and conditions. If the problem cannot be solved under these constraints, explain why not. 2. (3 points). Consider the following BNF grammar of expressions: h exp i ::= h simple i | h exp i + h exp i | h exp
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 04/10/2008 for the course CSE 755 taught by Professor Neelamsoundarajan during the Winter '05 term at Ohio State.

Ask a homework question - tutors are online