private void SubQueryCondition(QueryTree queryTree) { PredicateCondition(queryTree); if (_lookaheadFirst.TokenType == TokenType.And) { queryTree.Insert(FilterQueryLogicalOperator.and); DiscardToken(); SubQueryCondition(queryTree); } if (_lookaheadFirst.TokenType == TokenType.Or) { queryTree.Insert(FilterQueryLogicalOperator.or); DiscardToken(); SubQueryCondition(queryTree); } }
private void PredicateCondition(QueryTree queryTree) { var predicate = new PredicateModel(); if (_lookaheadFirst.Value == null) { throw new ApplicationException("Illegal query detected, enclose strings with a beginning ' and ending '"); } predicate.Field = _lookaheadFirst.Value; DiscardToken(); predicate.Operator = GetOperator(_lookaheadFirst); DiscardToken(); predicate.Value = _lookaheadFirst.Value; DiscardToken(); queryTree.Insert(predicate); }
public QueryTree Parse(List <Token> tokens) { LoadSequenceStack(tokens); PrepareLookaheads(); _queryTree = new List <QueryTree>(); Find(); DiscardToken(TokenType.SequenceTerminator); var qtToReturn = new QueryTree(); foreach (var qt in _queryTree) { qtToReturn.Insert(qt.GetRoot()); } return(qtToReturn); }
private void FindCondition() { var queryTree = new QueryTree(); if (_lookaheadFirst.TokenType == TokenType.OpenParenthesis) { DiscardToken(); SubQueryCondition(queryTree); DiscardToken(); _queryTree.Add(queryTree); } var op = GetLogicalOperator(_lookaheadFirst); if (op != null) { var singleNodeQT = new QueryTree(); singleNodeQT.Insert(op.Value); _queryTree.Add(singleNodeQT); DiscardToken(); FindCondition(); } }