antlr / antlr/antlr-php-runtime

Class ParseTreeProperty

Open
#7 4 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
PHP
Stars
97
Forks
18
Avg merge
12m
Merged PRs (30d)
2

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked Java API documentation for ParseTreeProperty and inspect the PHP runtime's Tree package for the missing entry point. The issue presents two incompatible implementation approaches but names no files, tests, or acceptance criteria; done requires maintainers to choose and specify a compatible design before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.