antlr / antlr/antlr4

JavaScript: what the heck do visitors return?

Open
#1,995 10 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
19k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

```
visitParent(ctx) {
console.log(JSON.stringify(
visitChildren()[1][0] ); <--- whoa!
}

visitChild(ctx) {
return new Child('something');
}
```

Now, instead of getting just "Child", visitParent gets Child wrapped in some structure.

To get to the Child object, I have to do something like ```visitChildren()[1][0]```

What's the wrapping stuff? Is [1][0] always correct, to get to the object I actually returned?

Insights greatly appreciated.

Contributor guide

Open the contributing guide

Research direction

The issue names no documentation file, implementation entry point, or test. Start by tracing the JavaScript visitor API and its visitChildren return structure, then document whether the [1][0] access is guaranteed and add or update a focused example or test showing the expected return value.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.