Cop4020 project - topic cexpr programming assignment your


Project - Topic: Cexpr Programming Assignment

Your assignment is to write a program using yacc (bison) and lex (flex) that implements a calculator of C integer expressions. The calculator will process expressions until it encounters EOF or invalid syntax. Each calculation is terminated by a semicolon. Tokens can be separated by whitespace (but no comments). After each calculation, the calculator prints its result. Tokens include integer numbers and 26 predefined integer variables. There will be one variable corresponding to each of the lowercase letters in the alphabet. The table below defines the C operators you need to implement. The operators are listed in order of decreasing precedence.

Yacc (bison) does provide mechanisms for specifying the associativity and precedence of operators in an unambiguous grammar. However, you are not allowed to use these mechanisms. Instead you should define extra non-terminals and productions to enforce the specified associativity and precedence for this assignment.

Rather than having a default value of zero for each of the predefined variables, you will treat the default variable as having an unknown value. If a variable's value is referenced without ever having been assigned a value, then the value of the expression should be designated as unknown. A variable's value becomes unknown when it is assigned an unknown value.

In addition to calculating an expression, two other commands are supported. The first is to dump the values of the different variables when the keyword dump is detected. The second is to reset all of the values of the different variables to unknown when the keyword reset is encountered.

You need to create files called cexpr.y, scan.l and makefile that will contain the parser, scanner and makefile. The makefile should make an executable called cexpr.exe. You should submit a single zip (tar) file that includes these three files, to Canvas project link.

The reference executable (cexpr.exe) is placed in ~uh/cop4020/proj4/cexpr.exe for your info.

Attachment:- Assignment File.rar

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Cop4020 project - topic cexpr programming assignment your
Reference No:- TGS02506454

Expected delivery within 24 Hours