JuliaLang / JuliaLang/JuliaSyntax.jl

Review trivia which can't be inferred from their node kind

Open
#223 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
293
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Some tokens becomes trivia after parsing has done its work. For example, parentheses in both `f(x)` and `(x)` only appear in the green tree as trivia. For the function call, the presence of parentheses can be inferred from the tree `(call f x)` because there's only one type of function call syntax. That is, we can reconstruct the trivia which isn't whitespace or comments.

In contrast, this is not the case for `(x)`, until #222 is merged because the green tree didn't represent grouping parentheses (these ended up as trivia on the parent node instead).

In general, it seems that a nice invariant for the green tree to have would be that

> Every piece of syntax can be inferred from the `kind`, `flags`, and list of nontrivia children, other than whitespace and comments.

Presumably there's cases other than #222 to fix - would be good to review all cases of `bump` used together with `TRIVIA_FLAG`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.