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();}

public static string GetNodeText(ITree t, IList<string> ruleNames){if (ruleNames != null){if (t is RuleContext){int ruleIndex = ((RuleContext)t).RuleIndex;string ruleName = ruleNames[ruleIndex];int altNumber = ((RuleContext)t).getAltNumber();if ( altNumber!=Atn.ATN.INVALID_ALT_NUMBER ) {return ruleName+":"+altNumber;}return ruleName;}else{if (t is IErrorNode){return t.ToString();}else{if (t is ITerminalNode){IToken symbol = ((ITerminalNode)t).Symbol;if (symbol != null){string s = symbol.Text;return s;}}}}}object payload = t.Payload;if (payload is IToken){return ((IToken)payload).Text;}return t.Payload.ToString();}
