Closed hawkw closed 10 years ago
We also need to come up with a mechanism for outputting the errors generated throughout the compilation process (from the lexer and parser as well as from semantic analysis). We should ideally come up with a mechanism for handling all of these errors in a standardized way.
Also, we should ensure that we generate errors that are formatted identically to Dr. Jumadinova's, especially because she said that she will be testing the submission for the checkpoint using a script.
I'd love @ArcticLight's input on this one.
so, here's a few basic observations that lead to a conclusion:
Therefore, if we're already holding a bunch of tables AND a table of compilation state while managing the compile, why not one more table? I propose a simple structure that holds pending warnings and errors. We do what we can during the recursive walk, updating the state as we go, and if there are any errors or warnings left when we're done, we print them. This also allows us to manage errors which only make sense in certain contexts, such as errors of "Unused type" or "Undeclared type" since we can push a Pending version of the error where we first see it, and then resume whatever generated the Pending error once we resolve it with another definition.
This is kind-of-done?
We need to determine how the Decaf compiler will handle errors. We need to determine how we will differentiate between fatal errors (that halt compilation) and warnings (that allow compilation to continue).
We also need to determine if
dcc
will continue semantic analysis after generating a fatal error, so that we can catch other errors in the program as well. It would be nice to report all of the errors in the program, rather than just the first one encountered; however, this may make some things more difficult, since, for example, type checking depends on scoping, and if we aren't able to scope the program correctly, it might confuse the type checker.I think Scala's heap-based error management construct (
Try[A]
) and possibly alsoFuture
s andPromise
s might be useful here.