static int findCodeTokens(L<S> tok, S... tokens) {
  ret findCodeTokens(tok, 1, false, tokens);
}

static int findCodeTokens(L<S> tok, boolean ignoreCase, S... tokens) {
  ret findCodeTokens(tok, 1, ignoreCase, tokens);
}

static int findCodeTokens(L<S> tok, int startIdx, boolean ignoreCase, S... tokens) {
  ret findCodeTokens(tok, startIdx, ignoreCase, tokens, null);
}

static HashSet<S> findCodeTokens_specials = lithashset("*", "<quoted>", "<id>", "<int>", "\\*");
static bool findCodeTokens_debug;
static int findCodeTokens_indexed, findCodeTokens_unindexed;
static int findCodeTokens_bails, findCodeTokens_nonbails;

static int findCodeTokens(L<S> tok, int startIdx, boolean ignoreCase, S[] tokens, O condition) {
  if (findCodeTokens_debug) {
    if (eq(getClassName(tok), "main$IndexedList2"))
      findCodeTokens_indexed++;
    else
      findCodeTokens_unindexed++;
  }
  // bail out early if first token not found (works great with IndexedList)
  if (!ignoreCase && !findCodeTokens_specials.contains(tokens[0])
    && !tok.contains(tokens[0] /*, startIdx << no signature in List for this, unfortunately */)) {
      ++findCodeTokens_bails;
      ret -1;
    }
  ++findCodeTokens_nonbails;
  
  int end = tok.size()-tokens.length*2+2, nTokens = tokens.length;
  outer: for (int i = startIdx | 1; i < end; i += 2) {
    for (int j = 0; j < nTokens; j++) {
      S p = tokens[j], t = tok.get(i+j*2);
      boolean match;
      if (eq(p, "*")) match = true;
      else if (eq(p, "<quoted>")) match = isQuoted(t);
      else if (eq(p, "<id>")) match = isIdentifier(t);
      else if (eq(p, "<int>")) match = isInteger(t);
      else if (eq(p, "\\*")) match = eq("*", t);
      else match = ignoreCase ? eqic(p, t) : eq(p, t);
      
      if (!match)
        continue outer;
    }
    
    if (condition == null || checkTokCondition(condition, tok, i-1)) // pass N index
      return i;
  }
  return -1;
}