private bool CanTokenBeFollowedByToken(ObjectPlacementPathHeightPatternToken token, ObjectPlacementPathHeightPatternToken nextToken) { if (nextToken.IsWhitespace()) { return(true); } if (token.IsClosingParanthesis()) { return(nextToken.IsComma()); } if (token.IsOpeningParenthesis()) { return(nextToken.IsDigit() || nextToken.IsMinusSign()); } if (token.IsComma()) { return(nextToken.IsDigit() || nextToken.IsLetter() || nextToken.IsMinusSign()); } if (token.IsDigit()) { return(nextToken.IsDigit() || nextToken.IsComma() || nextToken.IsClosingParanthesis()); } if (token.IsLetter()) { return(nextToken.IsOpeningParenthesis()); } return(true); }
private bool ValidateNoDigitsSeparatedByWhitespace(List <ObjectPlacementPathHeightPatternToken> patternTokens) { if (patternTokens.Count < 3) { return(true); } int currentTokenIndex = 0; while (currentTokenIndex < patternTokens.Count) { // Find the first whitespace token which follows a digit while (currentTokenIndex < patternTokens.Count) { ObjectPlacementPathHeightPatternToken token = patternTokens[currentTokenIndex]; if (token.IsWhitespace()) { bool previousTokenIsDigit = currentTokenIndex != 0 && patternTokens[currentTokenIndex - 1].IsDigit(); if (previousTokenIsDigit) { break; } } ++currentTokenIndex; } // Find the first non-whitespace token. If the token following it is a digit, we have an invalid token sequence. ++currentTokenIndex; while (currentTokenIndex < patternTokens.Count) { ObjectPlacementPathHeightPatternToken token = patternTokens[currentTokenIndex]; if (!token.IsWhitespace()) { if (token.IsDigit()) { LogInvalidSyntaxMessage("2 digits can not be separated by whitespace."); return(false); } else { ++currentTokenIndex; break; } } ++currentTokenIndex; } } return(true); }