{"id":109291,"date":"2022-12-09T21:38:19","date_gmt":"2022-12-09T21:38:19","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/project-on-grammars-computer-science-homework-help\/"},"modified":"2022-12-09T21:38:19","modified_gmt":"2022-12-09T21:38:19","slug":"project-on-grammars-computer-science-homework-help","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/project-on-grammars-computer-science-homework-help\/","title":{"rendered":"Project on grammars | Computer Science homework help"},"content":{"rendered":"<div id=\"\">\n<tr valign=\"top\">\n<td align=\"right\">Objective:<\/td>\n<td>To acquire a comprehensive understanding of the application of grammars and formal language theory to computing languages.<\/td>\n<\/tr>\n<tr>\n<td align=\"right\" valign=\"top\">Given:<\/td>\n<td>\n<p>Consider the following set of productions:<\/p>\n<table border=\"\" align=\"center\">\n<tbody>\n<tr>\n<td>\n<table>\n<tbody>\n<tr>\n<td>P01:<\/td>\n<td align=\"right\">FN<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>FN\u2013HEAD \u00a0 FN\u2013BODY<\/td>\n<\/tr>\n<tr>\n<td>P02:<\/td>\n<td align=\"right\">FN\u2013HEAD<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>TYPE \u00a0 id \u00a0\u00a0<strong><span>(<\/span><\/strong>\u00a0 PARAM\u2013LIST \u00a0\u00a0<strong><span>)<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P03:<\/td>\n<td align=\"right\">TYPE<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>char<\/span><\/th>\n<\/tr>\n<tr>\n<td>P04:<\/td>\n<td align=\"right\">TYPE<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>int<\/span><\/th>\n<\/tr>\n<tr>\n<td>P05:<\/td>\n<td align=\"right\">TYPE<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>real<\/span><\/th>\n<\/tr>\n<tr>\n<td>P06:<\/td>\n<td align=\"right\">PARAM\u2013LIST<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>TYPE \u00a0 id<\/td>\n<\/tr>\n<tr>\n<td>P07:<\/td>\n<td align=\"right\">PARAM\u2013LIST<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>PARAM\u2013LIST \u00a0\u00a0<strong><span>,<\/span><\/strong>\u00a0\u00a0 TYPE \u00a0 id<\/td>\n<\/tr>\n<tr>\n<td>P08:<\/td>\n<td align=\"right\">FN\u2013BODY<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><strong><span>{<\/span><\/strong>\u00a0\u00a0 VAR\u2013DECL \u00a0 STMT \u00a0\u00a0<strong><span>return \u00a0 (<\/span><\/strong>\u00a0\u00a0 EXPRESN \u00a0\u00a0<strong><span>) \u00a0 ; \u00a0 }<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P09:<\/td>\n<td align=\"right\">VAR\u2013DECL<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><span>\u03bb<\/span><\/td>\n<\/tr>\n<tr>\n<td>P10:<\/td>\n<td align=\"right\">VAR\u2013DECL<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>TYPE \u00a0 ID\u2013LIST \u00a0\u00a0<strong><span>;<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P11:<\/td>\n<td align=\"right\">VAR\u2013DECL<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>VAR\u2013DECL \u00a0 TYPE \u00a0 ID\u2013LIST \u00a0\u00a0<strong><span>;<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P12:<\/td>\n<td align=\"right\">ID\u2013LIST<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>id<\/td>\n<\/tr>\n<tr>\n<td>P13:<\/td>\n<td align=\"right\">ID\u2013LIST<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>ID\u2013LIST \u00a0\u00a0<strong><span>,<\/span><\/strong>\u00a0 id<\/td>\n<\/tr>\n<tr>\n<td>P14:<\/td>\n<td align=\"right\">STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><span>\u03bb<\/span><\/td>\n<\/tr>\n<tr>\n<td>P15:<\/td>\n<td align=\"right\">STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>SIMPLE\u2013STMT<\/td>\n<\/tr>\n<tr>\n<td>P16:<\/td>\n<td align=\"right\">STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>SELECT\u2013STMT<\/td>\n<\/tr>\n<tr>\n<td>P17:<\/td>\n<td align=\"right\">STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>REPEAT\u2013STMT<\/td>\n<\/tr>\n<tr>\n<td>P18:<\/td>\n<td align=\"right\">STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>SEQUENCE\u2013STMT<\/td>\n<\/tr>\n<tr>\n<td>P19:<\/td>\n<td align=\"right\">SIMPLE\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>ASSIGN\u2013STMT<\/td>\n<\/tr>\n<tr>\n<td>P20:<\/td>\n<td align=\"right\">SIMPLE\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>FN\u2013CALL\u2013STMT<\/td>\n<\/tr>\n<tr>\n<td>P21:<\/td>\n<td align=\"right\">ASSIGN\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>var \u00a0\u00a0<strong><span>=<\/span><\/strong>\u00a0\u00a0 EXPRESN \u00a0\u00a0<strong><span>;<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P22:<\/td>\n<td align=\"right\">EXPRESN<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>ARITH\u2013EXP<\/td>\n<\/tr>\n<tr>\n<td>P23:<\/td>\n<td align=\"right\">EXPRESN<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>BOOL\u2013EXP<\/td>\n<\/tr>\n<tr>\n<td>P24:<\/td>\n<td align=\"right\">ARITH\u2013EXP<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>TERM<\/td>\n<\/tr>\n<tr>\n<td>P25:<\/td>\n<td align=\"right\">ARITH\u2013EXP<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>ARITH\u2013EXP \u00a0 ADD\u2013OP \u00a0 TERM<\/td>\n<\/tr>\n<tr>\n<td>P26:<\/td>\n<td align=\"right\">ADD\u2013OP<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>+<\/span><\/th>\n<\/tr>\n<tr>\n<td>P27:<\/td>\n<td align=\"right\">ADD\u2013OP<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>\u2013<\/span><\/th>\n<\/tr>\n<tr>\n<td>P28:<\/td>\n<td align=\"right\">TERM<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>FAC<\/td>\n<\/tr>\n<tr>\n<td>P29:<\/td>\n<td align=\"right\">TERM<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>TERM \u00a0 MUL\u2013OP \u00a0 FAC<\/td>\n<\/tr>\n<tr>\n<td>P30:<\/td>\n<td align=\"right\">MUL\u2013OP<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>*<\/span><\/th>\n<\/tr>\n<tr>\n<td>P31:<\/td>\n<td align=\"right\">MUL\u2013OP<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>\/<\/span><\/th>\n<\/tr>\n<tr>\n<td>P32:<\/td>\n<td align=\"right\">FAC<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><strong><span>(<\/span><\/strong>\u00a0\u00a0 ARITH\u2013EXP \u00a0\u00a0<strong><span>)<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P33:<\/td>\n<td align=\"right\">FAC<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>OPD<\/td>\n<\/tr>\n<tr>\n<td>P34:<\/td>\n<td align=\"right\">OPD<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>var<\/td>\n<\/tr>\n<tr>\n<td>P35:<\/td>\n<td align=\"right\">OPD<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>const<\/td>\n<\/tr>\n<tr>\n<td>P36:<\/td>\n<td align=\"right\">BOOL\u2013EXP<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>RELN\u2013EXP<\/td>\n<\/tr>\n<tr>\n<td>P37:<\/td>\n<td align=\"right\">BOOL\u2013EXP<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>LOGIC\u2013EXP<\/td>\n<\/tr>\n<tr>\n<td>P38:<\/td>\n<td align=\"right\">RELN\u2013EXP<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>OPD \u00a0 RELN\u2013OPR \u00a0 OPD<\/td>\n<\/tr>\n<tr>\n<td>P39:<\/td>\n<td align=\"right\">RELN\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>==<\/span><\/th>\n<\/tr>\n<tr>\n<td>P40:<\/td>\n<td align=\"right\">RELN\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>!=<\/span><\/th>\n<\/tr>\n<tr>\n<td>P41:<\/td>\n<td align=\"right\">RELN\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>&lt;<\/span><\/th>\n<\/tr>\n<tr>\n<td>P42:<\/td>\n<td align=\"right\">RELN\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>&lt;=<\/span><\/th>\n<\/tr>\n<tr>\n<td>P43:<\/td>\n<td align=\"right\">RELN\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><strong><span>&gt;<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P44:<\/td>\n<td align=\"right\">RELN\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><strong><span>&gt;=<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P45:<\/td>\n<td align=\"right\">LOGIC\u2013EXP<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>OPD \u00a0 LOGIC\u2013OPR \u00a0 OPD<\/td>\n<\/tr>\n<tr>\n<td>P46:<\/td>\n<td align=\"right\">LOGIC\u2013EXP<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>LOGIC\u2013OPR \u00a0 OPD<\/td>\n<\/tr>\n<tr>\n<td>P47:<\/td>\n<td align=\"right\">LOGIC\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>and<\/span><\/th>\n<\/tr>\n<tr>\n<td>P48:<\/td>\n<td align=\"right\">LOGIC\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>or<\/span><\/th>\n<\/tr>\n<tr>\n<td>P49:<\/td>\n<td align=\"right\">LOGIC\u2013OPR<\/td>\n<td><span>\u2192<\/span><\/td>\n<th align=\"left\"><span>not<\/span><\/th>\n<\/tr>\n<tr>\n<td>P50:<\/td>\n<td align=\"right\">FN\u2013CALL\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>id \u00a0\u00a0<strong><span>(<\/span><\/strong>\u00a0 ARG\u2013LIST \u00a0\u00a0<strong><span>) \u00a0 ;<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P51:<\/td>\n<td align=\"right\">ARG\u2013LIST<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><span>\u03bb<\/span><\/td>\n<\/tr>\n<tr>\n<td>P52:<\/td>\n<td align=\"right\">ARG\u2013LIST<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>id<\/td>\n<\/tr>\n<tr>\n<td>P53:<\/td>\n<td align=\"right\">ARG\u2013LIST<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>ARG\u2013LIST \u00a0\u00a0<strong><span>,<\/span><\/strong>\u00a0\u00a0 id<\/td>\n<\/tr>\n<tr>\n<td>P54:<\/td>\n<td align=\"right\">SELECT\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><strong><span>if<\/span><\/strong>\u00a0\u00a0 CONDITION \u00a0 STMT \u00a0\u00a0<strong><span>else<\/span><\/strong>\u00a0\u00a0 STMT<\/td>\n<\/tr>\n<tr>\n<td>P55:<\/td>\n<td align=\"right\">CONDITION<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><strong><span>(<\/span><\/strong>\u00a0\u00a0 BOOL\u2013EXP \u00a0\u00a0<strong><span>)<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P56:<\/td>\n<td align=\"right\">REPEAT\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>DO\u2013STMT<\/td>\n<\/tr>\n<tr>\n<td>P57:<\/td>\n<td align=\"right\">REPEAT\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>WHILE\u2013STMT<\/td>\n<\/tr>\n<tr>\n<td>P58:<\/td>\n<td align=\"right\">DO\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><strong><span>do \u00a0 {<\/span><\/strong>\u00a0\u00a0 STMT \u00a0\u00a0<strong><span>} \u00a0 while<\/span><\/strong>\u00a0\u00a0 CONDITION \u00a0\u00a0<strong><span>;<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P59:<\/td>\n<td align=\"right\">WHILE\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td><strong><span>while<\/span><\/strong>\u00a0\u00a0 CONDITION \u00a0\u00a0<strong><span>do \u00a0 {<\/span><\/strong>\u00a0\u00a0 STMT \u00a0\u00a0<strong><span>} \u00a0 ;<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td>P60:<\/td>\n<td align=\"right\">SEQUENCE\u2013STMT<\/td>\n<td><span>\u2192<\/span><\/td>\n<td>STMT \u00a0 STMT<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td align=\"right\" valign=\"top\">Instructions:<\/td>\n<td>\n<ol>\n<ol>\n<li><span>(30 points)<\/span>\u00a0\u00a0 Rewrite the set of productions above in Extended Backus-Naur Form (EBNF).<\/li>\n<\/ol>\n<\/ol>\n<ol>\n<ol>\n<li><span>(35 points)<\/span>\u00a0\u00a0 Using a Push Down Automaton (PDA), determine if the following function is valid code according to the given set of productions.<\/li>\n<\/ol>\n<\/ol>\n<table border=\"\" align=\"center\">\n<tbody>\n<tr>\n<th align=\"left\">int Max ( int x, int y )\u00a0<br \/>\u00a0 \u00a0 {\u00a0<br \/>\u00a0 \u00a0 \u00a0 \u00a0 int z ;\u00a0<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 if ( x &gt;y )\u00a0<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 z = x ;\u00a0<br \/>\u00a0 \u00a0 \u00a0 \u00a0 else\u00a0<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 z = y ;\u00a0<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 return ( z ) ;\u00a0<br \/>\u00a0 \u00a0 }<\/p>\n<\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/p>\n<ol>\n<ol>\n<li><span>(35 points)<\/span>\u00a0\u00a0 Validate your answer in (2) by illustrating it with a derivation tree<\/li>\n<\/ol>\n<\/ol>\n<\/td>\n<\/tr>\n<tr>\n<td align=\"right\" valign=\"top\">Deliverable:<\/td>\n<td>\n<p>Submit a paper Times New Roman font, 12 pt., double-space lines). \u00a0 The project must contain an introduction which includes the purpose of the project. \u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>I attached the answers to 1 and 2 just look to make sure correct and write a paper.\u00a0<\/p>\n<\/td>\n<\/tr>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Objective: To acquire a comprehensive understanding of the application of grammars and formal language theory to computing languages. Given: Consider the following set of productions: P01: FN \u2192 FN\u2013HEAD \u00a0 FN\u2013BODY P02: FN\u2013HEAD \u2192 TYPE \u00a0 id \u00a0\u00a0(\u00a0 PARAM\u2013LIST \u00a0\u00a0) P03: TYPE \u2192 char P04: TYPE \u2192 int P05: TYPE \u2192 real P06: PARAM\u2013LIST \u2192 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-109291","post","type-post","status-publish","format-standard","hentry","category-education"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/109291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=109291"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/109291\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=109291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=109291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=109291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}