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

Request for Documentation on Parsing Rules for Trivia in swift-syntax #2582

Open
omochi opened this issue Apr 2, 2024 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@omochi
Copy link
Contributor

omochi commented Apr 2, 2024

Description

I'd like to request documentation on the rules for parsing Trivia.
There used to be documentation explaining the rules for parsing Trivia back when we were using libSyntax,
but it seems to have disappeared since the transition to swift-syntax.

The URL at the time was as follows.
https://github.com/apple/swift/blob/980d40951ff557047dce833d1d092b400bbc20db/lib/Syntax/README.md

Just to be sure, I searched both the repository and the documentation site, but I couldn't find it.

Understanding what constitutes the trailing trivia of a preceding token and
what becomes the leading trivia of a following token
is essential for implementing tools that process code.

It's challenging to deduce this behavior from the actual behavior alone,
so I believe it's necessary to have a document that explains this.

@omochi omochi added the enhancement New feature or request label Apr 2, 2024
@ahoppen
Copy link
Collaborator

ahoppen commented Apr 2, 2024

Tracked in Apple’s issue tracker as rdar://125747258

@ahoppen
Copy link
Collaborator

ahoppen commented Apr 5, 2024

Generally (if you don’t consider multi-line string literals, which have their own rules), all trivia up to a newline is trailing trivia and all trivia after a newline is leading trivia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants