The grammar below generates Boolean expressions in prefix notation:
B → O B B | not B | id O → and | or
a) Write an attribute grammar to translate Boolean expressions into fully parenthesized infix form. For example, expression and and a or b c d turns into the following fully parenthesized expression ((a and (b or c)) and d).
b) Now write an attribute grammar to translate the Boolean expressions into parenthesized expressions in infix form without redundant parentheses. Use the established convention that not has highest precedence, followed by and, followed by or, and and and or are left-associative. For example, the above expression turns into a and (b or c) and d.
answered for second part...plz don't dislike I requests to all of u..
Get Answers For Free
Most questions answered within 1 hours.