Open
Description
In the API for the runtime, as documented for Java in https://www.antlr.org/api/Java, we have a Class ParseTreeProperty in the Tree-package. It is to easily attach a value to a node in the parse tree. Java uses an IdentityHashMap for that, with the node / parse tree as key. In PHP we don't have such a datastructure, where we can use an object as key. That is probably why you left this class out in the PHP runtime?
My thoughts:
- to make it compatible with the general runtime API, we can implement another way to associate values with a node. Maybe using spl_object_id or spl_object_hash as a key/identity for the node.
- or do it the dirty PHP-way, where we can add values to any object: adding values directly to the node. Disadvantage: you change the tree, which might give problems if you want to reuse the tree for multiple applications (multiple listeners / visitors using the same tree).
My preference is option nr. 1, as it conforms the general API. Shall I make a proof of concept?
Maybe I'm overlooking something here and is this a non-issue... Please let me know your thoughts.