Compiler – Assignment 9 (Solution)

$ 20.99
Category:

Description

Attribute Grammars

Q1. Developing a simple calculator

Q1.1. Describe Context Free Grammar (CFG) for arithmetic expressions. Operations to consider are addition, subtraction, division and multiplication. Check that your grammar Is suitable for LR parsing.

Q1.2 We recently discussed about attribute grammars. Design an attribute grammar (by adding appropriate attributes and semantic rules) for the CFG developed in 1.1 to be able to evaluate the result of given arithmetic expression. The starting non-terminal symbol should have a single synthesized attribute whose value should be the result of the expression being parsed. Consider an example expression and illustrate how your solution works (using parse tree, dependency graph etc).

Submit a document describing your solution for Q1.

Q2. Implement a simple calculator (use LEX+YACC tools).
You have already designed a solution in Q1. Implement a simple calculator using tools such as YACC where we only need to describe the grammars designed in Q1 in the required format.

OPTIONAL: Consider other operations.

Reviews

There are no reviews yet.

Be the first to review “Compiler – Assignment 9 (Solution)”

Your email address will not be published. Required fields are marked *