-
Context:Some parser rules of the grammar of a language I am developing represent syntactic sugar. Instead of writing additional generation code for the AST nodes resulting from these rules, I want to rewrite the AST to eliminate the syntactic sugar. WorkaroundTo achieve this, I need to create a new object of a specific type whose properties are to reference objects accessible through the properties of the original syntactic sugar node. After creating this new object, I would substitute it for the syntactic sugar node in the AST. However, I have some challenges with the 1. The Problem with
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @soft-guy, we have a utility function |
Beta Was this translation helpful? Give feedback.
Hey @soft-guy,
we have a utility function
AstUtils.linkContentToContainer
that you can use for this exact purpose. During the AST construction, you can just ignore the$container
property (for example, by setting it toundefined!
), and then use the linked function to let the framework take over the assignment.