Sale!

Assignment 5 Semantic analysis

Original price was: $35.00.Current price is: $30.00.

Category:
Rate this product

CPSC 326: Homework Assignment 5
Goals:
• Develop a better understanding of semantic analysis as a front-end compilation stage.
• Practice working with the visitor pattern for traversing and coding against the AST.
• Practice writing unit tests and develop a full suite of parser regression tests.
You are free to use whatever IDE and machine you prefer for this class. However, to complete the
assignment, you will need git, g++ (version 11 or higher), cmake, make, the google test framework, and
valgrind installed. It can also be useful to have a debugger such as gdb installed as well. Each of these are
already installed on the remote development server (ada.gonzaga.edu) provided by the CS Department.
However, you may also install these programs on your own machine, via a virtual machine, running WSL2,
or on your own remote server. Note that you will also need a GitHub account for obtaining starter code
and for submitting your assignment.
Instructions:
1. Use the GitHub Classroom link (posted in Piazza) to copy the starter code into your own repository.
Clone the repository in the directory where you will be working on the assignment (e.g., onto ada
or your own machine).
2. Copy your various implementation files to date into the HW5 src directory. Your lexer, simple
parser, ast parser, and HW4 mypl file is is required for this assignment.
3. Modify your mypl.cpp program from HW-4 (see below).
4. Complete the SemanticChecker.
5. Ensure your code passes the unit tests provided in semantic_checer_tests.cpp within the tests
subdirectory.
6. Ensure your parser correctly handles the example files provided within the examples subdirectory.
Note that correct handling here means running ./mypl –check over each file does not throw any
errors and does not print anything.
7. Create ten additional unit tests for your SemanticChecker. Include a description of the tests you
created in your homework writeup.
8. Create a short write up as a pdf file named hw5-writeup.pdf. For this assignment, your write
up should provide a short description of any challenges and/or issues you faced in finishing the
assignment and how you addressed them along with a description of each of the unit tests you
created. Be sure your hw5-writeup.pdf file is in the main directory of your assignment (and not
within the src directory or any other subdirectory).
1
9. Submit your program. Be sure to add, commit, and push all assignment files to your GitHub repo.
You can verify that your work has been submitted via the GitHub page for your repo.
Additional Requirements: Note that the majority of information related to this assignment will be
provided in class, in lecture notes, and in the discussion section.
• Modify your mypl.cpp file from HW-4 so that the –check flag calls your semantic checker visitor.
Your code within mypl.cpp should look something like the following. Note that the snippet below
assumes that the lexer has already been created.
try {
ASTParser parser(lexer);
Program p = parser.parse();
SemanticChecker v;
p.accept(v);
} catch (MyPLException& ex) {
cerr << ex.what() << endl;
}
• Be sure to look through the typing rules provided as part of the lectures. While not comprehensive
in terms of all checks that must be performed by your SemanticChecker (e.g., see the unit tests),
many of the details are captured in the typing rules.
• You must develop interesting and non-trivial unit tests for this assignment. There are a number of
cases that are not covered in the unit tests. In addition, you might also try writing some MyPL
programs to get a better sense of what could go wrong in terms of types, etc. Your write up should
state why you thought each test would be interesting.
• While you have a good amount of time to finish the assignment, you will need to spread out your
work and get started early. This is likely the most difficult assignment of the MyPL implementation
steps.
Homework Submission and Grading. Your homework will be graded using the files you have pushed
to your GitHub repository. Thus, you must ensure that all of the files needed to compile and run your
code have been successfully pushed to your GitHub repo for the assignment. Note that this also includes
your homework writeup. This homework assignment is worth a total of 30 points. The points will be
allocated according to the following.
1. Correct and Complete (24 points). Your homework will be evaluated using a variety of different
tests (for most assignments, via unit tests as well as test runs using specific files). Each failed test
will result in a loss of 2 points. If 10 or more tests fail, but some tests pass, 4 points (out of the 24)
will be awarded as partial credit. Note that all 24 points may be deducted if your code does not
compile, large portions of work are missing or incomplete (e.g., stubbed out), and/or the specified
techniques, design, or instructions were not followed.
2
2. Evidence and Quality of Testing (2 points). For each assignment, you must provide additional
tests that you used to ensure your program works correctly. Note that for most assignments, a
specific set of tests will be requested. A score of 0 is given if no additional tests are provided, 1 if
the tests are only partially completed (e.g., missing tests) or the tests provided are of low quality,
and 2 if the minimum number of tests are provided and are of sufficient quality.
3. Clean Code (2 points). In this class, “clean code” refers to consistent and proper code formatting
(indentation, white space, new lines), use of appropriate comments throughout the code (including
file headers), no debugging output, no commented out code, meaningful variable names and helper
functions (if allowed), and overall well-organized, efficient, and straightforward code that uses standard coding techniques. In addition, when compiled, your code should not have any warnings. A
score of 0 is given if there are major issues, 1 if there are minor issues, and 2 if the “cleanliness” of
the code submitted is satisfactory for the assignment.
4. Writeup (2 points). Each assignment will require you to provide a small writeup addressing challenges you faced and how you addressed them as well as an explanation of the tests you developed.
Homework writeups do not need to be long, and instead, should be clear and concise. A score of 0
is given if no writeup is provided, 1 if parts are missing, and 2 if the writeup is satisfactory.
3

Reviews

There are no reviews yet.

Be the first to review “Assignment 5 Semantic analysis”

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

Scroll to Top