The following is a grammar that allows you to omit parentheses in infix algebraic expressions when the precedence rules remove ambiguity. For example, a + b * c means a + ( b * c ). However, the...


The following is a grammar that allows you to omit parentheses in infix algebraic expressions when the precedence rules remove ambiguity. For example, a + b * c means a + ( b * c ). However, the grammar requires parentheses when ambiguity would otherwise result. That is, the grammar does not permit left-to-right association when several operators have the same precedence. For example, a / b * c is illegal. Notice that the definitions introduce factors and terms.


The recognition algorithm is based on a recursive chain of subtasks: fi nd an expression → fi nd a term → fi nd a factor . What makes this a recursive chain is that fi nd an expression uses fi nd a term , which in turn uses fi nd a factor . Find a factor either detects a base case or uses fi nd an expression , thus forming the recursive chain. The pseudocode for the recognition algorithm follows:


Design and implement a class of infix expressions, as described by the given grammar. Include a method to recognize a legal infix expression.



Nov 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here