Skip to content

Allow IR nodes to retain the originating CST node #1312

@ggiraldez

Description

@ggiraldez

Follow-up from #1266, from these review comments:

By default, choice types and unique language terminals don't have an associated CST node in the IR nodes.

I imagine we will need the CST ref/location for very few nodes in the tree (mainly expressions).

I wonder if this should opt-in instead? something like model.retain_cst_node(identifier)...


I think some of the "unique" terminals in choices will need a ref to their CST node. For example: keywords that push literal values (true / false / etc...).

I wonder if this should also be opt-in instead? i.e. model.retain_cst_node(identifier), which will generate a sub-sequence for it:


And also, the association is through the node ID, but we may as well save the Rc<>:

Q: I wonder why is this a raw node ID rather than the node RC directly?

For linked non-terminal nodes this would make the default Debug implementation of IR nodes unusable for debugging, since they will recursively print the children nodes. We can override the Debug trait though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions