Grades and deadlines
-
Initial deadline: 23:59 on Wednesday 19 November
-
How to submit: Turn in your completed
lab4.2.ymlfile, along with everything in thesrc/mainfolder of your maven project.You must submit via the command line in order to preserve the folder structure. Use either of these two commands to do it:
club -csi413 -plab4.2 -f lab4.2.yml src/mainor
submit -c=si413 -p=lab4.2 lab4.2.yml src/main(you can download the club tool here)
If you used an AI tool to help with this lab (you should use Gemini), turn in a file
aichat.mdas well. Remember the course guidelines for the use of generative AI on labs. -
Grading:
In this lab you will complete the following tasks:
- Write a complete, working interpreter for one of the selected language, supporting closures and lexical scope.
- Thoroughly test your interpreter on the included programs as well as new, simpler programs that you write
If your submission meets the requirements for each task, you will receive 10 points towards your total lab grade.
-
Collaboration
You are free to discuss the lab with classmates (without looking at Java code), diagram out your solution, etc., as long as that collaboration is clearly documented in your YAML file.
After you have already written something, and it doesn’t work, you may also get debugging help from someone working on a different language than you, provided this help is clearly documented. Help never includes sharing any working code with a classmate.
-
Resubmissions:
We will follow the same resubmission policy for all labs this semester:
def points_earned(deadline, max_points, previous_submission=None): while current_time() < deadline: wait() submission = get_from_submit_system() if meets_all_requirements(submission): return max_points elif significant_progress(previous_submission, submission): return points_earned(deadline + one_week, max_points, submission) else: return 0
The languages
Each chosen language has a separate github repo with starter code:
Once you have chosen your language, you can clone the repo like this:
git clone https://github.com/si413usna/startlab.git -b lab4.2-XXXXXX lab4.2
replacing XXXXXX with easyas, simple, or ddcw.
Your task
For each chosen language, the starter code contains a partially working interpreter, which is able to handle mostly the Unit 3 stuff like variables, string and boolean operations, if statements, and while loops, with a single global scope.
In this lab, you will first need to understand the new language you are
working with. The best way to do that is to look at the example
programs, as well as the language syntax spec in tokenSpec.txt and
ParseRules.g4.
Then, you will need to add to the existing functionality to support function calls with closures and lexical scope, similar to the Scheme and Python examples we have seen in class. In particular, you will want to add:
- Some AST node(s) for function definitions (or lambdas)
- Some AST node(s) for function calls
- New visit methods in
ASTGento connect the parse tree to those new AST nodes - Support in the dynamically-typed
Valueclass for a Closures, which should combine a Frame (referencing environment) with the function or code to execute. - Support in the
Frameclass (as well asInterpreter.java) for parent frames and lexical scoping logic
This list is in no particular order, and in fact many of these tasks are kind of inter-related. Part of your challenge is to figure out how to work methodically and carefully, testing as you go, to build this magnificent piece of software.
This is the pinnacle of what we are asking you to do in this course. Your hard work so far has led you here, and we know you are ready for it. Good luck and have fun with it!