Starting from:

$29

Project 3 Tiger language using Bison

Project 3  Tiger language using Bison

Goal:
This assignment serves several purposes:
• to be familiar with Bison,
• to create the context free grammar for Tiger language, and
• to create the parser for Tiger language using Bison
Description:
This is a team project that build on the previous project. In this project you are required to use Bison
to build a parser for the Tiger language. More specifically, write the context free grammar for the
Tiger language. Please read Tiger language manual carefully before you start. The manual can be
found in the class repository\Document\Tiger folder.
Team Project Requirement:
Please review the following documents in the class repository:
• How to access the team repository
Each team will be assigned a team account, which should be shared by all team members in
the same group. Then follow the same steps as you have done in previous projects:
1. Create master repository CSCI4160/project3 on ranger using the team account
2. Each team member should clone the repository on his/her local machine, and do his own
duty.
3. When required, the team member should commit all changes to local repository and then
push to ranger so other team members can access it.
4. In order to view works submitted by other students, a team member needs to pull from
ranger repository.
• Requirements for team projects
Class repository\Document\team requirements.doc
The team should submit the following documents while working on the project:
1. Time log report.
The time log report is used to monitor the progress of the project. Each team is required to
submit 3 time log reports. Each report should specify the major works that has been done and
estimated time needed to finish the project,
o The first time log report should be submitted within 2-3 days after the project is
assigned. This report should specify the roles of team members, and estimated time
needed from each team member.
o One time log reports to monitor the progress of the project (alpha version) and test
cases.
o One report to monitor the progress of the final version of the project..
The time log report pattern file can be found at “project3\timelog” folder.
2. Test cases:
The test cases are actually a Tiger program used to test the project (alpha version). The pattern
of test case file can be found at: “project3\Testing”
3. Test report
The test report summarizes the detected errors on alpha version of the project. The format of
the file can be found at: “project3\Testing”Important Dates and Deadlines:
Monday Tuesday Wednesday Thursday Friday Saturday Sunday
27
Project
assigned
28 29 30
1st time log
report due
1 (Oct.)
2 3 4 5 6 7
2nd time log
report due
8
9
Project
(alpha
version)
and test
cases due
10 11 12
1st test
report due
3rd time log
report due
13 14
Final
Project due
15
16 17 18
Notes:
• All reports/files are due at 5:00am on the due day.
What to do in this project?
Come up with context free grammar for Tiger language, and use Bison to generate the parser for it.
Your grammar should have as few shift-reduce conflicts as possible, and no reduce-reduce conflicts.
When you compile your parser file, Bison will output information about the number of shift-reduce
conflicts as well as the number of reduce-reduce conflicts. If your grammar has a reduce-reduce
conflict, please talk to me to see how to get rid of it.
Most Tiger CFG can be found in the brief manual located at “class
repository\Document\Tiger\BriefManual.pdf”. However, some changes is required to make it work.
In the tiger.yy file, the precedence level and association of operators should be specified based on the
Tiger manual.
Extra rules should be provided to recover from errors. You grammar should generate the same output
on the sample file example.tig as the one provided by the instructor.
When defining CFG for Tiger language, please ignore the following features:
• Records, i.e. record definition and record expression
• Arrays, i.e. array definition and array expression
• All other features that are only tied with records and arrays.
Set up environment:
I strongly suggest teams to use the sample Visual Studio solution provided by me in the class
repository.
1. Choose a tiger.ll from your team members (typically the one with highest grades). Correct all
existing errors. Copy the tiger.ll to project3\BisonProject\MainDriver, and make the following
change:a. Replace the line #include “tokens.h” by #include “tiger.tab.hh”. This is required
because there is no tokens.h, and all token definition will be in tiger.tab.hh file, which
is generated by Bison.
b. In tiger.ll file, please remove rules recognizing the following tokens:
LBRACE RBRACE LBRACKET RBRACKET ARRAY
2. Put your grammars in tiger.yy file, which is the only file the team needs to work on.
3. To compile your project,
a. Compile tiger.ll. This step can be skipped if there is no change since the last
compilation of tiger.ll.
b. Compile tiger.yy.
c. Build the MainDriver solution.
4. There are two ways to debug your grammar,
a. In the sample solution provided by the instructor, there is a file “tiger.output” under
“FlexBison Tools”\Resource Files within Visual Studio environment. This file is
generated everytime tiger.yy is parsed. It contains all state information of your
grammars.
b. Reset yydebug to 1 at line 29 at main.cpp file. This will generate debug information on
terminal when compiling a tiger file. This approach is probably hard to understand.
Instructor provided files in the class repository
The following files are provided by the instructor:
• Project3\Testing: This folder contains test reports..
• Project3\Timelog: This folder contain all time log reports..
• Project3\AlphaVersion: This folder contains the alpha version of the project. Please put
tiger.yy file only in this folder.
• Project3\Rubric3.docx: the rubric file for this project.
• Project3\BisonProject: This folder contains all source files and required visual studio files
o Skeleton source files provided in the sample project are listed below:
 tiger.ll: an empty file. Should be replaced.
 lex.yy.c: generated by Flex when compiling tiger.ll
 tiger.yy: a skeleton file for tiger CFG.
 tiger.tab.hh & tiger.tab.cc: generated by Bison when compiling tiger.yy.
 tiger.output: debug file for CFG
 ErrorMsg.h: contains the definition of error handler
 main.cpp: the driver
 test0.tig and test1.tig: test cases of tiger language
• Description3.pdf: this file
• Rubric3.doc: the rubric used to grade this assignment.
• Test0.txt and test1.txt. expected output for test0.tig and test1.tig, respectively.
How to submit
1. Once you have finished, submit the project in the following way:
• Group leader needs to make sure files and reports are placed in the right folder, and have
been pushed to the master repository in ranger.
• Any commit of the project after the deadline is considered as cheating. If this
happens, the latest version before the deadline will be graded, and you may receive
up to 50 points deduction.• Each team is required to submit hard copies of the following files. Please put copies
of these files in a folder/envelope of size 9 x 12. You can buy folders from lab
assistant at KOM 351.
• Test case
• testing report
• 3 timelog reports
• Tiger.yy (alpha version. )
• Tiger.yy (final version)
Write down team number, and names of all team member on the cover. Give the
folder/envelope to the instructor at the beginning of the class on the due day.
2. You can check your overall grade by pull rubric3.doc from the master repository after the notice
from the instructor.

More products