julia
e9bbdafa - Allow parsing to `Expr`-structured `SyntaxTree` (#60474)

Commit
2 days ago
Allow parsing to `Expr`-structured `SyntaxTree` (#60474) This change allows parsing to "`EST`" (`SyntaxTree` with Expr structure for compatibility with macros) by adding a way to convert `RawGreenNode` to `EST`. This is pretty similar to our existing `RawGreenNode`->`Expr` conversion `node_to_expr`, so there's some unfortunate duplication here, but I did this over making `node_to_expr`'s output generic for a few reasons: - `RawGreenNode`->`Expr` is production code we're using today and is the reference I'm testing this change against, so I don't want to screw with it. - Producing `SyntaxTree` means working with different constraints: - We can't efficiently mutate the list of children after the tree is created. - Nodes that are created and never used will stick around in the graph. - Each node needs to remember what node it was converted from. - I've cleaned up the algorithm by postponing recursion on child nodes until after we decide what child nodes there will be in most cases. - In a future where we pass provenance from parsing to macro-expansion by default, we can just delete the old conversion and use `RawGreenNode`->`EST`->`Expr` in its place.
Author
Parents
Loading