// this sets up the lookahead token without actually consuming it static string PeekToken() { // give back the lookahead token again if we already computed it if (strLookaheadToken != null) return strLookaheadToken;

strLookaheadToken = GetToken();

return strLookaheadToken; }

// this reads a token from the input stream and is unaware of lookahead concerns static string GetToken() { if (ichInput >= strInput.Length) return null;

// fetch the next character from the input stream static char getc() { if (ichInput >= strInput.Length) return '\0';

return strInput[ichInput++]; }

// fixed size stack -- we could do better if we needed to but // this is good enough for this test static bool[] evalStack = new bool[16]; static int GetFactNumber(string fact) { if (!dictFacts.ContainsKey(fact)) dictFacts.Add(fact, dictFacts.Count);

return dictFacts[fact]; }

static void SetFact(string fact) { // facts that are mentioned in no predicates may be disregarded if (!dictFacts.ContainsKey(fact)) return;