-
Notifications
You must be signed in to change notification settings - Fork 8
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
Line numbers for better error handling (WIP) #42
Conversation
I'm not a fan of having the line number in Lexer. Since Parser manages the progress of the Lexer, it could catch the errors thrown in Lexer (and itself) and rethrow them with the line number added. That way, errors in Lexer don't need to be rewritten. Not for that reason anyway. Also for added consistency with the code we have already the error message should start with |
@stebanos This looks better? |
Hey Kunal, yes this is better. Will you also add in the error re-throwing? |
Sure! |
There are still errors thrown in the |
Hehe, I think you misunderstood my last request. You added in the PhraseParser:
A similar thing could be done in the Interpreter class if the phrase has access to its line number. |
Oh! 🤦♂️ |
The Interpreter can access the phrase through |
Yes, that is what I plan to do. 👍 |
Sorry about the commit message 😓 |
Thanks, well done! |
@@ -434,7 +434,7 @@ class PhraseLexer extends Lexer { | |||
} else if (this.checkEscapeChar('}')) { | |||
result += '}'; | |||
this.advance(); | |||
this.advance(); | |||
this.advance();line |
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.
I know this is now merged, but I don't understand this code. What's the line at the end? Just a typo?
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.
I think that is what it is 😓
I am sorry, let me just change it.
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.
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.
👍
This presents a proposal for solving #40.
I have used the method to solve #30. You can check the method by trying to reproduce the mentioned there.
If this looks fine, I can try to implement this on all the errors thrown in the code.