I'm about to implement a listener to traverse an antlr4-generated parse tree in TypeScript.
I have already a working listener implementation written in Java and have to translate most parts of the existing code. At first I generated JavaScript parser, lexer & listener and added type definitions for antlr4.
Given grammar:
functionCall:
constant '%'
// more rules...
| FUNCTION_NAME arguments ')'
Now I need to access terminal nodes inside a method by asking the context object, in Java you could do this like so:
@Override
public void enterFunctionCall(ExpressionParser.FunctionCallContext ctx) {
String functionName = ctx.FUNCTION_NAME().getText();
// more code...
}
}
How can I access a terminal node inside a method like FUNCTION_NAME in TypeScript?
question from:
https://stackoverflow.com/questions/66063331/antlr-accessing-terminal-node-in-typescript 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…