[Solved] CS 431 Programming language concepts Homework 1 solved

$25

File Name: CS_431_Programming_language_concepts_Homework_1_solved.zip
File Size: 508.68 KB

SKU: [Solved] CS 431 Programming language concepts Homework 1 solved Category: Tag:
5/5 - (1 vote)

Homework 1September 11, 2018For this homework, you will write BNF grammars. You do not need toresolve ambiguity such as operator precedence or associativity. Your grammarsdo not consider white spaces.Assume that there exists the non-terminal <num> that represents numbers.1. De ne a non-terminal <var> that represents the variables a, b, c, x, y, andz.2. De ne a non-terminal <aop> that represents binary arithmetic operators+, -, *, /, ^.3. De ne a non-terminal <aexp> that represents arithmetic expressions. Thegrammar should accept expressions such as: ((a 5) / c + 1) * 2,2 * (x + 3) * y + z / a, and 2^44 + b. Please utilize the non-terminalssuch as <var>, <num>, and <aop>.4. De ne a non-terminal <bop> that represents binary boolean operators &&and jj. Note that 0jj0 is quoted since j is also used as separator for thegrammar.5. De ne a non-terminal <cop> that represents binary comparison operators<,<=,==,!=,>=,>6. De ne a non-terminal <bexp> that represent logical expressions (i.e. booleanexpressions). The grammar should accept expressions such as:!(a/2 <= 10 && 5 != c)a < c || b > 0Note that logical expressions include negation operator ! and the booleanconstant true and false. You should utilize the non-terminals <aexp>,<bop>, <cop>.7. De ne a non-terminal <Stmt> that represents statements that include as-signments, while loops, and if-statements (with optional else-part.) Thestatements may include arithmetic, comparison, and boolean expressions.De ne a non-terminal <Stmts> that represents zero or more statements.1Note that <Stmt> and <Stmts> are mutually dependent.You may use the special non-terminal <empty> to represent nothing.You should utilize the non-terminals <var>, aexp, <bexp>.Here is program that can be represented by the non-terminal <Stmts>.b = true;y = 2;while(!b && y < x) {if ((y (y/x)*x) == 0) {b = false;}}if(b) {z = y/x;}else {z = 1;}Here is another program that can be represented by <Stmts>.x = 1;y = x;if (a > x) {while (x <= a) {x = x + 1;y = y * x;}}2

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS 431 Programming language concepts Homework 1 solved
$25