Milestone #2: Front-End Completion¶
Due: Friday February 17th at 11:59pm
This milestone will require you to complete the front-end of the compiler along with beginning the back-end generation with producing LLVM code.
Getting started¶
You will not be creating a new repository for every milestone. Continue to work out of the same repository as Milestone #1 for all remaining milestones and the final submission of the compiler.
Language Overview: GoLite¶
Please make sure you read over the document that describes the language we will be implementing this quarter: Language Overview
Milestone Requirement: Abstract Syntax Tree¶
You must design and construct an abstract syntax tree based on the language specification and formal grammar. You must determine the appropriate representations for your nodes based on the formal grammar and must construct during the parsing phase. Please refer back to the lecture slides and videos for tips and suggestions about the AST construction.
Milestone Requirement: Semantic Analysis¶
After constructing the AST, the final phase of the front-end must validate the AST to ensure that the program conforms to the static semantics of the language. Your validity checks must include those mentioned in the description of the Language Overview. The semantic analysis phase must report an error if an appropriate main function is not defined. You must check to ensure that if a function returns a type that all control-flow paths have a return statement. This will require a bit of bookkeeping that you will need to think about. For example,
//Standard Case
func foo (num int) int {
return num;
}
//Control-flow case
func bar (num int) int {
if (num == 0) {
return 1;
} else {
if (num >= 1) {
return 1;
}else {
return -1;
}
}
}
If any of these return
statements are removed then an error should be thrown.
Milestone Requirement: Intermediate Representation¶
This specification will be posted in week 6 by Professor Samuels
Command-line Options Augmented¶
For this milestone, the must augment the compiler with the additional command line argument flags:
-ast
: Produces a print out of the AST generated by the compiler after parsing. We are not requiring a specific printing format. You are free to print the AST as you wish. However, you must defineString()
methods for each AST node to print out its representation as string.
Grading and What to Submit¶
You must provide the following to get full credit for this milestone:
You can reuse the same Golite files you submitted for milestone #2 for testing purposes. You must include additional test programs that would produce an error in the semantic analysis phase but not in the parsing phase.
A
README
file that states how to read the printing of your-ast
and-llvm
command line options.
The milestone is 5% of your grade and the exact weights for grading are:
5% credit: All required parts are fully implemented.
4% credit: AST Construction, Semantic Analysis, are fully completed is implemented by a few edge cases do not work.
3% credit: AST Construction, Semantic Analysis, are partially completed and need more work.
0% credit: No solution provided or none of the above requirements have been met.
Submission¶
Before submitting, make sure you’ve added, committed, and pushed all your code to GitHub. You must submit your final work through Gradescope (linked from our Canvas site) in the “Milestone #2” assignment page via two ways,
Uploading from Github directly (recommended way): You can link your Github account to your Gradescope account and upload the correct repository based on the homework assignment. When you submit your homework, a pop window will appear. Click on “Github” and then “Connect to Github” to connect your Github account to Gradescope. Once you connect (you will only need to do this once), then you can select the repository you wish to upload and the branch (which should always be “main” or “master”) for this course.
Uploading via a Zip file: You can also upload a zip file of the assignment directory.