Skip to content

Full account of comments in the AST #13865

Open
@ekpyron

Description

@ekpyron

Tooling asked us to (potentially optionally) include all comments in the AST for being able to support pretty-printing ASTs to near-identical sources (except whitespace differences, accounting for which would definitely go too far).

There's related discussion already in e.g. #4559.

We'll need to weigh the complexity this would induce for scanning and parsing and check if this can be done in a reasonable amount of time (since this is non-critical).

We can consider removing comments on the expression level from the scope of this, since they may be a larger hassle than comments on the statement level.

We'd also need to decide whether to introduce full AST nodes (maybe that'd be the way to go for statement-level comments) or fields similar to the documentation field used for natspac comments (that may be the only choice for comments on the expression level, if we even consider those).

Some justification for spending time on this otherwise tangential issue is that we could use such comments for testing AST-based properties like the annotations produced by #13378 in isoltest by introducing special comments with test expectations. In that sense, this weakly relates to our roadmap task #13722

Metadata

Metadata

Assignees

Labels

low effortThere is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.selected for developmentIt's on our short-term development

Type

No type

Projects

Status

ICE-Box

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions