/// <summary> /// Checks if the token accepts a context token before it. /// Returns true if it does; False if it is null or does not. /// </summary> /// <param name="token">The token to check</param> /// <returns>Flag indicating if the token can use a context type.</returns> private bool TokenAcceptsContext(Token token) { if (token == null) return false; return token.AcceptsContext(); }
/// <summary> /// This methods compares the 2 input tokens by their stored integer positions and /// returns a -1 if the first input token's position is smaller than the second. /// A 1 is returned if the reverse is true. /// No 2 tokens should have the same positions. However, should such an error arise, a 0 is returned. /// </summary> /// <param name="x">The first token</param> /// <param name="y">The second token to be compared with</param> /// <returns>-1, 1, or 0, indicating the results of the comparison</returns> private int CompareByPosition(Token x, Token y) { int xPosition = x.Position; int yPosition = y.Position; if (xPosition < yPosition) { return -1; } else if (xPosition > yPosition) { return 1; } else { Debug.Assert(false, "Two tokens with same position!"); return 0; } }