Milestone 1: Model

Dear Computer

Project: Spreadsheet

Milestone 1: Model

In this first milestone, you'll develop the model of your spreadsheet. A model is the set of abstractions that represent the core structures of an application. Models are meant to be separate from any particular user interface, making them reusable and easy to test. In the case of your spreadsheet, your model is a set of abstractions representing a two-dimensional grid of cells and formulas and data that can go in the cells.

Your spreadsheet will eventually have its own programming language for expressing formulas. Milestone 2 is about lexing, parsing, and translating that language into an executable form. This milestone doesn't touch on the language itself, but it does have you build the abstractions that your someday interpreter will use to build and evaluate abstract syntax trees. You'll design the interface for this grid in milestone 3—with hopefully no changes to the model.

Expression Hierarchy

A model of a program is built out of abstractions for assignment statements, conditionals, loops, the many different kinds of expressions, and so on. For this milestone, write abstractions for these expression structures:

Implement these following the pattern discussed in lecture.

Translater

Implement a visitor that translates an AST into some other language. Follow the pattern shown in lecture.

Evaluator

Implement a visitor that evaluates an AST down to a primitive node. Follow the pattern shown in lecture. Typecheck each operation and raise exceptions when the operation cannot be performed.

Grid

Some of the operations, like cell rvalues and statistical functions, need to access other cells. That means you need to store the cells in some sort of collection. Define a grid abstraction that manages all the cells. Choose a data structure that makes sense to you. Model each cell as a bundle of three pieces of state:

Give the grid the following operations:

Runtime

Define a Runtime abstraction to manage an executing program's runtime environment, as discussed in lecture. Have it hold also hold a reference to the grid so that you can evaluate cell rvalues. If an cell is reference, raise an error that you can catch later on.

Submission

To submit your milestone, follow the instructions. In particular, do these three things:

In your video, demonstrate adding several expressions to a grid and serializing and evaluating them. Include at least these expressions that are expressed in a hypothetical syntax:

The syntax is just an example. You'll be building trees manually out of your model classes. #[...] is a cell rvalue, and [...] is a cell lvalue. Ensure that evaluating these produces the correct results. Show also some expressions that fail to typecheck.

Show also some programs that fail to typecheck. Include these three expressions and others of your own crafting:

In your video, don't comment on or show every single line of code in your video. Select a few representative snippets. Do comment on programming language ideas that interest you or challenged you. If you use a language feature, algorithm, or data structure not discussed in class, as is likely if you use an LLM for assistance, you must explain how each deviation works and why it is better. If you do not include these explanations, your submission will not be accepted.

Be prepared to explain any code that you submit during the code review.

← Recording and Submitting