Skip to content
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

Merged
merged 5 commits into from
Apr 18, 2024
Merged

Conversation

NicholasRM
Copy link
Contributor

  • 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

@NicholasRM NicholasRM requested a review from lutzhamel March 30, 2024 23:38
Copy link
Collaborator

@lutzhamel lutzhamel left a 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
Copy link
Collaborator

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 ['@', ',', '[', '(', '"', "'"]:
Copy link
Collaborator

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

@NicholasRM NicholasRM requested a review from lutzhamel April 6, 2024 20:33
@NicholasRM
Copy link
Contributor Author

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!

Copy link
Collaborator

@lutzhamel lutzhamel left a 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?

@NicholasRM NicholasRM requested a review from lutzhamel April 17, 2024 21:28
Copy link
Collaborator

@lutzhamel lutzhamel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@lutzhamel
Copy link
Collaborator

Feel free to merge it!

@NicholasRM NicholasRM merged commit 2a755c6 into dev-2.0.2 Apr 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants