コード例 #1
0
ファイル: PredicateParser.cs プロジェクト: spreeker/waebric
        /// <summary>
        /// Parser for Predicate
        /// </summary>
        /// <returns>Parsed Predicate</returns>
        public Predicate ParsePredicate()
        {
            Predicate predicate = null; //Empty predicate

            if (TokenStream.HasNext() && TokenStream.Peek(1).GetValue().ToString() == "!")
            {   //Not Predicate
                NotPredicate notPredicate = new NotPredicate();

                //Skip ! token
                NextToken("!", "! predicate", '!');

                //Parse predicate after !
                notPredicate.SetPredicate(ParsePredicate());

                predicate = notPredicate;
            }
            else
            {   //Other predicates exists out of an expression
                Expression expression = expressionParser.ParseExpression();

                if (TokenStream.HasNext() && TokenStream.Peek(1).GetValue().ToString() == ".")
                {   //IsPredicate
                    predicate = ParseIsPredicate(expression);
                }
                else
                {   //ExpressionPredicate
                    predicate = ParseExpressionPredicate(expression);
                }
            }

            //Check for && or || predicates
            if (TokenStream.HasNext() && TokenStream.Peek(1).GetValue().ToString() == "&" && TokenStream.Peek(2).GetValue().ToString() == "&")
            {   //AndPredicate
                return ParseAndPredicate(predicate);
            }
            else if (TokenStream.HasNext() && TokenStream.Peek(1).GetValue().ToString() == "|" && TokenStream.Peek(2).GetValue().ToString() == "|")
            {   //OrPredicate
                return ParseOrPredicate(predicate);
            }
            return predicate;
        }
コード例 #2
0
ファイル: SyntaxNodeVisitor.cs プロジェクト: spreeker/waebric
 public virtual void Visit(NotPredicate predicate)
 {
     VisitSubNodes(predicate);
 }