christoff-buerger / racr

Metacompiler library supporting incremental transformation based on reference attribute grammar controlled rewriting.
MIT License
30 stars 9 forks source link

RACR-meta: separation and testing of annotation facilities #66

Closed christoff-buerger closed 8 years ago

christoff-buerger commented 8 years ago

To simplify the core implementation of RACR and, in particular, clearly identify and elaborate the essential facilities required for meta-instantiation and reasoning (cf. issues #62 and #63 ), the existing abstract syntax tree annotation functionalities should become a separate Scheme library, that can be loaded additionally to (racr-meta core) if required.

Since unit tests for the existing annotation facilities are missing, they have to be added to ensure correct refactoring and improve code coverage.

christoff-buerger commented 8 years ago

Finished and tested. The following changed in addition to the original proposal:

Note: The current implementation uses a hashtable to store for every node its annotations. This strategy is problematic because the usage of nodes as keys prohibits their garbage collection. The problem is attenuated by removing nodes from the table when their last annotation is removed. However, instead of a global annotation table, a special annotation field should be added to each node, as it was handled in the previous implementation. The field was a waste of memory though, if no annotations were used at all. In the long run, such a field could be added on demand, by leveraging on future meta-protocol facilities of RACR-meta. The general idea is to modify the RACR-specification language when loading the annotations library such that its abstract syntax tree constructors add an internal annotations field.