Virtlink / redgreen-aterms

An ATerms library that uses red-green trees.
4 stars 1 forks source link

Origins #5

Open Virtlink opened 8 years ago

Virtlink commented 8 years ago

Spoofax uses origin tracking to track where terms came from. This information must be added to the green tree, and be kept under transformations.

Apanatshka commented 8 years ago

Doesn't adding this to green tree make all green nodes unique and unshareable in normal parse trees? Is the width info not enough to reconstruct origin info in the red trees?

Virtlink commented 8 years ago

Yes and yes. Adding origins will makes each node unique and therefore unshareable, and the width info should be enough to reconstruct the origin info.

However, once we start moving subtrees and terms around (term rewriting, transformations, desugarings), the only way to know where a term came from (e.g. for error reporting, highlighting, etc) is by storing the origin information explicitly with the term.

Apanatshka commented 8 years ago

I can think of other ways.. Like a transformed term points back to the origin parse tree, where it came from. Of course this might be problematic with the original parse tree needing to stay alive all the time and further and further away from the information source that you derive origin info from..