Skip to content

Introduce RawSyntaxData.ParsedToken #597

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

Merged
merged 1 commit into from
Aug 17, 2022

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Aug 16, 2022

A new RawSyntax data variation. This is intended to be used for parsed token. Actual usage will be in follow-ups.

In this variation, unlike the existing MaterializedToken, leading/trailing trivia are stored in a SyntaxText form, and are lazily materialized by a function registered in SyntaxArena. Since the parser doesn't need to materialize them while parsing, it'd gain the "parsing" performance boost, in exchange for a performance reduction when accessing trivia.

@rintaro rintaro requested review from bnbarham and CodaFi August 16, 2022 18:49
@rintaro rintaro requested a review from ahoppen as a code owner August 16, 2022 18:49
@rintaro rintaro changed the title Introduce RawSyntaxData.ParsedToken Introduce RawSyntaxData.Payload.ParsedToken Aug 16, 2022
@rintaro rintaro changed the title Introduce RawSyntaxData.Payload.ParsedToken Introduce RawSyntaxData.ParsedToken Aug 16, 2022
@rintaro
Copy link
Member Author

rintaro commented Aug 16, 2022

@swift-ci Please test

@rintaro rintaro force-pushed the rawsyntax-parsedtoken branch 4 times, most recently from d272eb7 to 326efb3 Compare August 16, 2022 22:00
@rintaro
Copy link
Member Author

rintaro commented Aug 16, 2022

@swift-ci Please test

@@ -24,10 +24,17 @@ internal struct RawSyntaxData {
/// Token with lazy trivia parsing.
///
/// The RawSyntax's `arena` must have a valid trivia parsing function to
/// lazily materialize the leading/trailing trivia.
/// lazily materialize the leading/trailing trivia xpieces.
Copy link
Member

Choose a reason for hiding this comment

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

Typo?

Suggested change
/// lazily materialize the leading/trailing trivia xpieces.
/// lazily materialize the leading/trailing trivia pieces.

struct ParsedToken {
var tokenKind: RawTokenKind

/// Whole of this token including leading/trailing trivia.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Whole of this token including leading/trailing trivia.
/// Whole text of this token including leading/trailing trivia.

A new RawSyntax data variation. This is intended to be used for parsed
tokens. Actual usage will be in follow-ups.

In this variation, unlike the existing `MaterializedToken`, leading/trailing
trivia are stored in a SyntaxText form, and are lazily materialized by a
function registered in `SyntaxArena`. Since the parser doesn't need to
materialize them while parsing, it'd gain the "parsing" performance boost,
in exchange for a performance reduction when accessing trivia.
@rintaro rintaro force-pushed the rawsyntax-parsedtoken branch from 1b2c2ce to b68716f Compare August 17, 2022 07:58
@rintaro
Copy link
Member Author

rintaro commented Aug 17, 2022

@swift-ci Please test

@rintaro rintaro merged commit 0e2b31e into swiftlang:main Aug 17, 2022
@rintaro rintaro deleted the rawsyntax-parsedtoken branch August 17, 2022 14:57
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