alanmmckay / KLEINcompiler

A compiler written in Python to translate KLEIN programs into TM assembly language. A group project for the Translation of Programming Languages class at University of Northern Iowa.
1 stars 0 forks source link

Error Handling #65

Open alanmmckay opened 4 years ago

alanmmckay commented 4 years ago

Our error handling started out strong, but stalled out as I had to take on larger work loads. This is something that could be improved upon.

Our parse errors could use good error messages; I believe parse table indexes are being output at this point in time.

Semantic errors could use some work too - the outputs are pretty minimal.

alanmmckay commented 4 years ago

I've updated our type checking error messages. They are more informative. Unfortunately we don't have the line number being output when a parse or semantic error is thrown. There is a disconnect in relation to the set of tokens the scanner hands off to the parser. That is, the line in which a token occurs is lost when this data structure is created.

This connection can be reestablished by storing the line property of the scanner within each token class instantiation; that is, create a line property within the token class and a method to retrieve it. This data can then be output when a parse error occurs. Further more, this information can be passed and stored in each relevant AST node when it is created; that is, have a relevant AST node have a line property and a method to retrieve it.

It's doubtful that I'll be able to implement this in time, but this would be the path to achieve it.

alanmmckay commented 4 years ago

Noting that a comment delimiter requires an immediate space within the comment range.