-
Notifications
You must be signed in to change notification settings - Fork 10
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
Milestone 5: Disallow Invalid Breakpoints #318
Conversation
NicholasRM
commented
Mar 30, 2024
- Check that line numbers and function and file names are valid at the current state of the program
- Prohibit the creation of breakpoints on lines or functions that do not exist or in files which have not been loaded yet
- Display appropriate error messages when these checks fail
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.
Hi Nick, please check out my comments and make appropriate changes. Holler if you have any questions. Thanks!
asteroid/mad.py
Outdated
if len(line) == 0: | ||
print("error: cannot place breakpoints on blank lines") | ||
return False | ||
# If the line starts with any of these tokens, it is a valid statement and can accept a breakpoint |
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 is very fragile, if the language evolves by introducing new tokens this will break and will prevent users from setting break points. Is there a way to do this in the lexer for example where it is natural for the user to extend collections when introducing new tokens. See the parser file where we define collection at the beginning.
asteroid/mad.py
Outdated
return False | ||
# If the previous or next lines begins with any of these symbols, the current line is in the middle of a statement | ||
if prev: | ||
for start in ['@', ',', '[', '(', '"', "'"]: |
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.
see my comment above, having these collection arbitrarily inside the code makes the code fragile
Hey! Thanks for bringing this to my attention. I changed the strategy from manually checking the line and its surrounding lines to one that parses that line and any lines follow it. In doing so, MAD will only set a breakpoint once the line can be correctly parsed. If there are no more lines to parse, the line is blank, or the line number is outside of the file, MAD will reject the breakpoint with an error message. Please let me know if this looks good or if I should change this further! |
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.
Interesting approach invoking the parser to determine whether or not we are looking at valid break lines.
The only reservation I have is that Asteroid can be used in different modes, for example, Asteroid can be used with the -F flag putting into functional programming mode. Will your approach still work in this case?
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.
Looks good!
Feel free to merge it! |