CSE 755, Assignment #1Due: 7 April ’06.1. (3 points). Consider the followingBNFgrammar:hlstringi::=hsihsihsi::=a|b|c|ahsi |bhsi |chsiAdd appropriate attributes and conditions to the grammar so that onlyhlstringis that satisfy the fol-lowing condition are allowed: every occurrence of ‘a’ is immediately preceded by a ‘b’andfollowedby a ‘c’. In other words, each occurrence of ‘a’ is sandwiched betweenbandc. (Thus, for example,‘bacbbcbac’ is legal, but not ‘babbcbc’.) Use synthesized attributes or inherited attributes, or a combi-nation. Do not change theBNFgrammar; 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 problemcannot be solved under these constraints, explain why not.2. (3 points). Consider the following BNF grammar of expressions:hexpi::=hsimplei | hexpi+hexpi | hexpi * hexpihsimplei::=hnumberi | hvariableiwherehnumberi
This is the end of the preview.
access the rest of the document.