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

ignore comments? #82

Open
andreyorst opened this issue Jul 2, 2020 · 3 comments
Open

ignore comments? #82

andreyorst opened this issue Jul 2, 2020 · 3 comments

Comments

@andreyorst
Copy link
Contributor

Parinfer Rust should be fast enough to strip away comments before processing and migrate unbalanced quote issues that original Parinfer had. Are there any plans for such feature?

@eraserhd
Copy link
Owner

The problem with the issue you've linked to is that the comment is no longer a comment, but a semicolon inside a string. There's not a way to detect that AFAIK, though if you have ideas, I'm open. When the quote is inserted, parinfer sees a valid string followed by possibly valid code.

Parinfer and parinfer-rust largely does ignore comments. Recently, I've merged some PRs that handle different cases in Scheme and Lisp that were not previously handled, thanks to recent contributors.

@andreyorst
Copy link
Contributor Author

I was thinking lately about comment caching. E.g. when Parinfer can ensure that buffer is correct, it can cache comment positions. When user removes, or inserts " Parinfer knows, that comments should not become part of the string, and by using cache skips comments inside incomplete string. Although this approach is quite fuzzy

@eraserhd
Copy link
Owner

eraserhd commented Jul 15, 2020

I've been thinking that the "can ensure the buffer is correct" part is an AI-complete problem. But maybe it's not a hard problem but requires the persistence of some state and the analysis of a number of cases?

  • Is it always true that a quote in a comment should not close a string when the user inserts a quote before the comment?
  • What happens if the user inserts a quote after the comment, after having inserted one before the comment?
  • What should happen if there are two, or another even number of quotes in the comment? It seems like for consistency, the file should still be considered broken even though it would parse.
  • What should happen if there are three, or another odd number of quotes in the comment?
  • What should happen if there are multiple comments with quotes in them?
  • What should happen if a quote in a comment is preceded by a backslash?
  • What should happen if a quote in a comment is preceded by a #\ in Scheme?
  • What happens if the user deletes a quote, making the file unbalanced, is it the same?
  • For opening quote?
  • For closing quote?
  • What happens if the user breaks the file by inserting a backslash before a quote?
  • How do we detect the user inserting a quote before a comment with a quote, so we store state to mark that quote as "ignored", and then the user inserts a backslash just before the quote, turning it into a character? We have to somehow make the file valid even though the user has inserted a quote.

That's off the top of my head, not a thorough analysis yet...

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

No branches or pull requests

2 participants