public void checkRuleArgs(Grammar g, List<GrammarAST> rulerefs) {
		if ( rulerefs==null ) return;
		for (GrammarAST ref : rulerefs) {
			String ruleName = ref.getText();
			Rule r = g.getRule(ruleName);
			GrammarAST arg = (GrammarAST)ref.getFirstChildWithType(ANTLRParser.ARG_ACTION);
			if ( arg!=null && (r==null || r.args==null) ) {
				errMgr.grammarError(ErrorType.RULE_HAS_NO_ARGS,
						g.fileName, ref.token, ruleName);

			}
			else if ( arg==null && (r!=null && r.args!=null) ) {
				errMgr.grammarError(ErrorType.MISSING_RULE_ARGS,
						g.fileName, ref.token, ruleName);
			}
		}
	}
For same rule compare values from next index:
TOKEN_WITH_SAME_VALUES: 'asdf' | 'asdf';
For different rules compare from start value:
TOKEN1: 'asdf';
TOKEN2: 'asdf';
tool/src/org/antlr/v4/semantics/SymbolChecks.java