For this phase, you will use Lex tool for writing the scanner and Yacc tool for writing the parser for a programming language called AA.
– Logic: &&,||,!
– Relational: ==, <>, <, <=, >,>=
The table below shows all AA operators from highest to lowest precedence, along with their associativity.
Table 1: precedence and associativity table
Operator |
Description |
Associativity |
! |
Unary Logical NOT |
right to left |
∗/ |
Multiplication/Division |
left to right |
+− |
Addition/ Subtraction |
left to right |
<, <=, >,>= |
Relational |
left to right |
=<> |
Equality |
left to right |
&& |
Logical AND |
left to right |
|| |
Logical OR |
left to right |
= |
Assignment |
right to left |
Identifiers: should start with capital letter and can include small, capital letters, underscores, or digits.
Literals: INT LITERAL e.g. 12345, STRING LITERAL e.g. "Hello"and DBL LITERAL e.g. 3.14.
When YACC finds input that doesn’t match the grammar, it automatically termi- nates with the message ’Syntax error’. You will need to implement an error routine (yyerror) that also prints out the line number before this termination, and a main method that read AA code from a file. Print an appropriate message in case of no syntax error. Build your parser using the grammar below:
Write the Lex and Yacc file for AA language as described above. Once you built your parser, you should be able to parse AA programs. If you want to test your code, consider the following program.
This program should be compiled and have no errors. Note that this program does not cover all functionalities that could be tested based on the given specification. Test your code thoroughly. If the input program is in different syntax than the given grammar, your parser should report an error.
You must deliver one zip including:
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of