text: public static String getNodeText(Tree t, List<String> ruleNames) {if ( ruleNames!=null ) {if ( t instanceof RuleContext ) {int ruleIndex = ((RuleContext)t).getRuleContext().getRuleIndex();String ruleName = ruleNames.get(ruleIndex);int altNumber = ((RuleContext) t).getAltNumber();if ( altNumber!=ATN.INVALID_ALT_NUMBER ) {return ruleName+":"+altNumber;}return ruleName;}else if ( t instanceof ErrorNode) {return t.toString();}else if ( t instanceof TerminalNode) {Token symbol = ((TerminalNode)t).getSymbol();if (symbol != null) {String s = symbol.getText();return s;}}}Object payload = t.getPayload();if ( payload instanceof Token ) {return ((Token)payload).getText();}return t.getPayload().toString();}