Open acbart opened 4 years ago
So CAIT actually wraps AST nodes in CAIT nodes, but mirrors all of the base AST node functionality so that you SHOULD be able to treat them as AST nodes if I remember correctly. So you could pass the root node of a match to Tifa, if it can take in an AST, and then TIFA can just traverse over the CAIT version of the tree instead when it does it's usual activities.
TIFA walks the AST and abstractly evaluates the program. At each step of the tree, it has a best guess (or guesses, technically) about what the current type of that expression is. We could easily produce a dictionary that maps instances of AST nodes from the tree to the type that was determined.
The biggest potential application of this is connecting that data back to CAIT. If you found an expression match in the source code, TIFA could tell you what type of value it is - not just when it is a Name, but when it's anything!
Student code:
Instructor code:
Not sure what the exact interface should look like; I kind of prefer the idea that Tifa would have a function rather than this being a method inside CAIT. However, I'm open to alternative ideas.