Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
167 views
in Technique[技术] by (71.8m points)

java - Antlr - Accessing terminal node in TypeScript

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...