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

ast: improve AST node documentation #2803

Open
Boshen opened this issue Mar 25, 2024 · 3 comments
Open

ast: improve AST node documentation #2803

Boshen opened this issue Mar 25, 2024 · 3 comments
Assignees
Labels
A-ast Area - AST

Comments

@Boshen
Copy link
Member

Boshen commented Mar 25, 2024

While I was working with syn, I found the documentation on AST nodes really helpful, we should do the same.

https://docs.rs/syn/latest/syn/index.html#structs

@Boshen Boshen added good first issue Experience Level - Good for newcomers A-ast Area - AST labels Mar 25, 2024
@rzvxa
Copy link
Collaborator

rzvxa commented Mar 26, 2024

On this subject, one thing that makes me struggle is that I can't find a clear way to get AstNode from a given ast struct/enum. How should it be done? I guess it is possible to search for it through the nodes but I was looking for a faster way.


Edit

I'm looking for a way to get either AstNode or the AstNodeId for a given expression(or any other AST type for that matter).

@rzvxa
Copy link
Collaborator

rzvxa commented Mar 26, 2024

Is it possible to add the ast_node_id to every AST node referencable via an AstNode? It can be stored in a cell similar to identifiers so we can assign them in the semantic.

It will make getting the node's parent, etc easier and would eliminate the need to pass reference on enter_node and leave_node while also providing a way to access the AstNode in VisitMut, Both enter and leave events can pass the AstNodeId instead of AstNode, and we can also access the AstNode easily within our visit methods.

Right now I can't see any clear way to access an AstNode from its let's say expression, statement, etc.

Having AstNodeId on the struct itself would also allow us to get rid of the AstNode structure and make the AstNodes struct SOA.

@Boshen
Copy link
Member Author

Boshen commented Mar 26, 2024

The requirement for ast_node_id has been brought up a couple times in the past, I think it's worthy to create a separate issue, bike-shed it and then implement it.

@Boshen Boshen self-assigned this May 14, 2024
@Boshen Boshen removed the good first issue Experience Level - Good for newcomers label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST
Projects
None yet
Development

No branches or pull requests

2 participants