コード例 #1
0
ファイル: Expression.cs プロジェクト: Klzfire/SQLGeneration
        /// <summary>
        /// Attempts to match the expression item with the values returned by the parser.
        /// </summary>
        /// <param name="attempt">The parser currently iterating over the token source.</param>
        /// <param name="itemName">The name of the item in the outer expression.</param>
        /// <returns>The results of the match.</returns>
        public MatchResult Match(IParseAttempt attempt, string itemName)
        {
            MatchResult result = new MatchResult()
            {
                ItemName = itemName, IsMatch = true
            };

            foreach (ExpressionItem detail in expression.Items)
            {
                IParseAttempt nextAttempt = attempt.Attempt();
                MatchResult   innerResult = detail.Item.Match(nextAttempt, detail.ItemName);
                if (innerResult.IsMatch)
                {
                    attempt.Accept(nextAttempt);
                    result.Matches.Add(innerResult);
                }
                else
                {
                    nextAttempt.Reject();
                    if (detail.IsRequired)
                    {
                        result.IsMatch = false;
                        return(result);
                    }
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: Options.cs プロジェクト: Klzfire/SQLGeneration
 /// <summary>
 /// Attempts to match the expression item with the values returned by the parser.
 /// </summary>
 /// <param name="attempt">The parser currently iterating over the token source.</param>
 /// <param name="itemName">This value will be empty for an options list.</param>
 /// <returns>The results of the match.</returns>
 public MatchResult Match(IParseAttempt attempt, string itemName)
 {
     foreach (ExpressionItem option in options)
     {
         IParseAttempt nextAttempt = attempt.Attempt();
         MatchResult   innerResult = option.Item.Match(nextAttempt, option.ItemName);
         if (innerResult.IsMatch)
         {
             attempt.Accept(nextAttempt);
             return(innerResult);
         }
         nextAttempt.Reject();
     }
     return(new MatchResult()
     {
         IsMatch = false
     });
 }
コード例 #3
0
ファイル: Expression.cs プロジェクト: kobynet/SQLGeneration
 /// <summary>
 /// Attempts to match the expression item with the values returned by the parser.
 /// </summary>
 /// <param name="attempt">The parser currently iterating over the token source.</param>
 /// <param name="itemName">The name of the item in the outer expression.</param>
 /// <returns>The results of the match.</returns>
 public MatchResult Match(IParseAttempt attempt, string itemName)
 {
     MatchResult result = new MatchResult() { ItemName = itemName, IsMatch = true };
     foreach (ExpressionItem detail in expression.Items)
     {
         IParseAttempt nextAttempt = attempt.Attempt();
         MatchResult innerResult = detail.Item.Match(nextAttempt, detail.ItemName);
         if (innerResult.IsMatch)
         {
             attempt.Accept(nextAttempt);
             result.Matches.Add(innerResult);
         }
         else
         {
             nextAttempt.Reject();
             if (detail.IsRequired)
             {
                 result.IsMatch = false;
                 return result;
             }
         }
     }
     return result;
 }
コード例 #4
0
ファイル: Options.cs プロジェクト: kobynet/SQLGeneration
 /// <summary>
 /// Attempts to match the expression item with the values returned by the parser.
 /// </summary>
 /// <param name="attempt">The parser currently iterating over the token source.</param>
 /// <param name="itemName">This value will be empty for an options list.</param>
 /// <returns>The results of the match.</returns>
 public MatchResult Match(IParseAttempt attempt, string itemName)
 {
     foreach (ExpressionItem option in options)
     {
         IParseAttempt nextAttempt = attempt.Attempt();
         MatchResult innerResult = option.Item.Match(nextAttempt, option.ItemName);
         if (innerResult.IsMatch)
         {
             attempt.Accept(nextAttempt);
             return innerResult;
         }
         nextAttempt.Reject();
     }
     return new MatchResult() { IsMatch = false };
 }