Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will use top-down parsing rather than bottom-up parsing (as implemented using YACC). Consider Boolean expressions, with the following operations: and, or,

In this assignment, you will use top-down parsing rather than bottom-up parsing (as implemented using YACC).
Consider Boolean expressions, with the following operations: and, or, and not (standard associativity and precedence), brackets are allowed. If below you are asked to "write ...", then you have to include the required description as a part of your documentation. If you are asked to "implement...", then you have to write a program.
Part 1. Write an S-attributed syntax directed translation for Boolean expressions with the following tokens:
true, false, and brackets, which can be used to evaluate these expressions. Note: carefully study examples from the textbook of S-attributed syntax directed translations for arithmetic expressions, to learn how to design them to express correct precedence and associativity rules.
Then, write an L-attributed translation resulting from removing left recursion. Note: carefully study examples from the textbook showing how left-recursive S-attributed translations can be converted to L-attributed translations.
Finally, implement a lexical analyzer (use Lex or write it by hand) and a recursive-descent translator based on the above translation.
Examples:
true and not false
not false or (false and not false and true or false)
are both correct, and evaluate to true, but
1 and true
is invalid.
------------------------------------------------------
* You have to use C++ or C
* And you have to look at the textbook (Aho, A.A., Sethi, R., & Ullman, J.D. (1986). Compilers. Principles, Techniques, and Tools. Boston, MA: Addison-Wesley, ISBN: 0201100886.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago