Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help with parts 1-6! For this homework, you will write BNF grammars for some types of expressions and statements. You do not need to
Please help with parts 1-6!
For this homework, you will write BNF grammars for some types of expressions and statements. You do not need to resolve ambiguity such as operator precedence or associativity. Your grammars do not consider white spaces. For example, the following grammar defines arithmetic expressions with the non-terminal denotes the binary arithmetic operators. You should quote all tokens like this example. This grammar accepts expressions such as: (ab)/c((a5)/c+1)22(x+3)y+z/a244+b 1. Using regular expressions, define the non-terminal num that represents numbers and define the non-terminal var that represents variables. 2. Define the non-terminal that represents binary boolean operators \& and . 3. Define the non-terminal that represents binary comparison operators =,> 4. Define the non-terminal that represents logical expressions (i.e. boolean expressions). The grammar should accept expressions such as: !(a/20 Note that logical expressions include negation operator ! and the hoolean constant true and false. You should utilize the non-terminals bop,cop. 5. Draw an abstract syntax tree for !(a+20 6. Define the non-terminal \&Stmts> that represents zero or more statements, where each statement is either an assignment, a while-loop, or an if-statement (with optional else-part.) Here is program that can be represented by the non-terminal . b= true; y=2; while (!b&kStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started