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

Cleanup recovery of grammar comments #6

Closed
apalala opened this issue May 7, 2017 · 3 comments
Closed

Cleanup recovery of grammar comments #6

apalala opened this issue May 7, 2017 · 3 comments
Labels

Comments

@apalala
Copy link
Collaborator

apalala commented May 7, 2017

# comments retain the # and are output as (* *) comments.

Prettification of comments is not well defined.

It's best to stick to Python-style (#) comments.

@apalala apalala added the bug label May 7, 2017
apalala added a commit that referenced this issue Apr 21, 2019
@apalala apalala added this to To do in release-plan Apr 21, 2019
@apalala
Copy link
Collaborator Author

apalala commented Mar 21, 2021

Comments can be added to the TatSu grammar for rule and option. The corresponding classes in grammars would have a comment field for the pretty-printer to use.

Some tweaks may be needed for comments right before a rule definition, and right after, before the first element.

PEG allows for this.

Complications would be on the pretty printer (most important), though the code generator could also try to do its part.

@apalala
Copy link
Collaborator Author

apalala commented Aug 20, 2023

The current design for attempting recovery of comments sucks!

This needs a better strategy, or deletion by giving grammar writers the responsibility for comment recovery.

@apalala
Copy link
Collaborator Author

apalala commented Aug 24, 2023

I dealt with this issue when parsing COBOL and NATURAL. I'm closing to think about it when I need to do something alike again. Not all grammars are easy when comment recovery is attempted.

I'd take a look at the new PEG Python grammar for Python.

My subconscious says that this would be manageable with tokenization, as was used in the PEG Python grammar, more so when now in TatSu Buffer is one implementation of Tokenizer.

This issue will come back. I just don't want to leave it open without a design, strategy, or pull request.

@apalala apalala closed this as completed Aug 24, 2023
release-plan automation moved this from Triage to Done Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
release-plan
  
Done
Development

No branches or pull requests

1 participant