@Test
	public void testVisitTerminalNode() {
		String input = "A";
		VisitorBasicLexer lexer = new VisitorBasicLexer(new ANTLRInputStream(input));
		VisitorBasicParser parser = new VisitorBasicParser(new CommonTokenStream(lexer));

		VisitorBasicParser.SContext context = parser.s();
		assertEquals("(s A <EOF>)", context.toStringTree(parser));

		VisitorBasicVisitor<String> listener = new VisitorBasicBaseVisitor<String>() {
			@Override
			public String visitTerminal(TerminalNode node) {
				return node.getSymbol().toString() + "\n";
			}

			@Override
			protected String defaultResult() {
				return "";
			}

			@Override
			protected String aggregateResult(String aggregate, String nextResult) {
				return aggregate + nextResult;
			}
		};

		String result = listener.visit(context);
		String expected =
			"[@0,0:0='A',<1>,1:0]\n" +
			"[@1,1:0='<EOF>',<-1>,1:1]\n";
		assertEquals(expected, result);
	}
This test verifies the basic behavior of visitors, with an emphasis on
{@link AbstractParseTreeVisitor#visitTerminal}.
runtime-testsuite/test/org/antlr/v4/test/runtime/java/api/TestVisitors.java