-
Notifications
You must be signed in to change notification settings - Fork 656
Automatic code generation for formatter #1997
Comments
I opened an "RFC" draft PR that adds a tentative design for this in #1998 |
Does it tackle the first bullet point of the task? |
It does so indirectly: I haven't done anything to address the second part though, so in the meantime I still had to include a placeholder implementation of |
The match expression in |
The new code-gen is neat. I've a few usability suggestions
|
@leops is there more work you plan to do on the codegen side or can we close this for the time being? |
No there isn't any work I plan to do on the formatter codegen for now, I'll close this |
We should be able to create code automatically, every time we run the xtask
syntax
.This task will be disruptive and will apply the following changes:
cst.rs
will be automatically generated, the whole file. If a new node is created, this file should have a new node created (and imported)This is my proposal:
Main folders
The root folder will be the language. For now we have all
Js*
nodes, they will live inside ajs/
folder. Once we will introduce new languages, new folders will pop up:ts/
folder forTs*
nodes;jsx/
folder forJsx*
nodes;Sub folders
All our nodes contains a "concept" in their name: statement, expression, object member, binding, etc. We could use those concepts as sub folders of the main folders. If a AST node name contains
Expression
, it will be placed inside theexpression/
folder, if it containsObjectMember
, it will be placed insideobject_member/
folder. And so on.Any*
element,JsAnyArrayElement
js
folderjs/any/
folder because it contains theAny
keywordarray_element.rs
and it will contain the following code:Rest of elements
For the name of the file, I am a bit conflicted. I would personally leave the whole name.
JsDoWhileStatement
=>js/statement/do_while_statement.rs
JsReturnStatement
=>js/statement/return_statement.rs
JsComputedMemberExpression
=>js/expression/computed_member_expression.rs
Ideally we could remove the "concept" from their name, but I'm not sure if it could create more issues.
The generated file will contain
The text was updated successfully, but these errors were encountered: