public bool VerifyNexts(ProgressiveList <string> nexts, bool dontWorryAboutOrder = false, Func <Token, Tokens, bool> checker = null) { bool ret = true; int state = GetState(); bool begun = true; if (dontWorryAboutOrder) { begun = false; } Token token; while ((token = tokens.Next()) != null) { var ntoken = nexts.Next(); if (ntoken == null) { if (!begun) { return(false); } return(ret); } if (token.text != ntoken) { if (!begun) { nexts.Back(); continue; } ret = false; break; } else { if (!begun) { if (checker == null) { begun = true; } else if (checker != null) { int prev = GetState(); if (!checker(token, this)) { nexts.Back(); } else { begun = true; return(true); } RestoreState(prev); } } } } RestoreState(state); if (!begun) { ret = false; } return(ret); }
/// <summary> /// Return a token and backwards the pointer /// </summary> /// <returns>The back.</returns> public Token Back() { return(tokens.Back()); }