org.antlr.v4.runtime.tree.AbstractParseTreeVisitor Java Examples
The following examples show how to use
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AstTSRendererTest.java From doov with Apache License 2.0 | 6 votes |
@Test void mapping() { TypeScriptParser parser = TypeScriptParserFactory.parse(CharStreams.fromString(mapping_stmt)); assertThat(parser.getNumberOfSyntaxErrors()).isEqualTo(0); CallExpressionContext callExpressionContext = parser.callExpression(); System.out.println(callExpressionContext.getText()); callExpressionContext.accept(new AbstractParseTreeVisitor<Object>() { @Override public Object visitChildren(RuleNode node) { if (node instanceof CallExpressionContext) { CallExpressionContext call = (CallExpressionContext) node; System.out.println(call.getText()); if (call.identifierName() != null) { System.out.println(call.identifierName().getText()); } if (call.memberExpression() != null) { System.out.println(call.memberExpression().getText()); } } return super.visitChildren(node); } }); }