-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modular error printing #50
base: master
Are you sure you want to change the base?
Conversation
fputs("Unexpected character:\n", stream); | ||
BarToken_print(compiler->bar, stream); | ||
|
||
if(fprintf(stream, "\n%*s^", (int) (compiler->position - 1), " ") < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're likely gonna use the exact same trick inside the token
module; might be worth extracting the string formatting into a helper method.
Update NoteCompiler to make use of error strings
Update Interpreter to use error strings
char* bar; | ||
NoteCompilerState state; | ||
size_t bar_length; | ||
char* filename; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we pass the filename in the constructor here, we should probably do that for all the other modules as well.
(Maybe not for the interpreter, if the idea is to be able to potentially load modules from different files?)
Also need to think about scope. (Caller needs to guarantee the string stays around for as long as the compiler/lexer whatever is used. This is fine, but should really be documented.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Thinking more about this, we might want to store the (pointer-to) filename in the tokens instead. There's little sense in having the line information in one place, and the file name in another.)
Closes #38