/// <summary> /// Handles the next character while inside a parameter. /// </summary> /// <param name="context">The current parsing context.</param> private static void HandleInParameter(ParserContext context) { if (context.IsMasked) { // All characters allowed if (context.CurrentCharacter == '\'') { if (context.IsNextCharQuote()) { // Masked ', so skip next character and continue context.AppendParameter(); context.SkipOne(); } else { // End of masked parameter context.LogicalPosition = ConstraintPosition.AfterParameter; context.AddParameter(); } } else { // All characters allowed context.AppendParameter(); } } else { switch (context.CurrentCharacter) { case ' ': // Space after parameter is allowed context.LogicalPosition = ConstraintPosition.AfterParameter; if (context.CurrentParameter.Length > 0) context.AddParameter(); break; case ',': // End of parameter context.LogicalPosition = ConstraintPosition.InParameters; if (context.CurrentParameter.Length > 0) context.AddParameter(); break; case ')': // At end of parameters context.LogicalPosition = ConstraintPosition.AfterParameters; if (context.CurrentParameter.Length > 0) context.AddParameter(); break; case '[': case ']': case '(': case '\'': // Invalid delimiters without masking throw new ConstraintParserException(Errors.CreateHResult(ErrorCodes.ConstraintParser_HandleInParameter_ParamUnmaskedChar), string.Format(Properties.Resources.ConstraintParser_Parse_UnmaskedChar, context.CurrentCharacter), context.StringPosition); default: // All other characters allowed in parameter context.AppendParameter(); break; } } }
/// <summary> /// Handles the next character while inside the parameters. /// </summary> /// <param name="context">The current parsing context.</param> private static void HandleInParameters(ParserContext context) { switch (context.CurrentCharacter) { case ' ': // Space between parameters is allowed break; case ',': // Comma must be set after first constraint case '[': case ']': case '(': // Invalid characters within parameters if unmasked throw new ConstraintParserException(Errors.CreateHResult(ErrorCodes.ConstraintParser_HandleInParameters_ParamCharInvalid), string.Format(Properties.Resources.ConstraintParser_Parse_InvalidCharInParameters, context.CurrentCharacter), context.StringPosition); case ')': // End of parameters context.LogicalPosition = ConstraintPosition.AfterParameters; break; case '\'': // Parameter is masked context.IsMasked = true; context.LogicalPosition = ConstraintPosition.InParameter; break; default: // First character of parameter context.LogicalPosition = ConstraintPosition.InParameter; context.AppendParameter(); break; } }