/// <summary>Parse the query</summary> /// <returns>Evaluator</returns> internal virtual Evaluator Parse() { tq.ConsumeWhitespace(); if (tq.MatchesAny(combinators)) { // if starts with a combinator, use root as elements evals.Add(new StructuralEvaluator.Root()); Combinator(tq.Consume()); } else { FindElements(); } while (!tq.IsEmpty()) { // hierarchy and extras bool seenWhite = tq.ConsumeWhitespace(); if (tq.MatchesAny(combinators)) { Combinator(tq.Consume()); } else { if (seenWhite) { Combinator(' '); } else { // E.class, E#id, E[attr] etc. AND FindElements(); } } } // take next el, #. etc off queue if (evals.Count == 1) { return(evals[0]); } return(new CombiningEvaluator.And(evals)); }
/// <summary> /// Parse the query /// </summary> /// <returns>Evaluator</returns> private Evaluator Parse() { _tq.ConsumeWhitespace(); if (_tq.MatchesAny(combinators)) { // if starts with a combinator, use root as elements _evals.Add(new StructuralEvaluator.Root()); Combinator(_tq.Consume()); } else { FindElements(); } while (!_tq.IsEmpty) { // hierarchy and extras bool seenWhite = _tq.ConsumeWhitespace(); if (_tq.MatchesAny(combinators)) { // group or Combinator(_tq.Consume()); } else if (seenWhite) { Combinator(' '); } else { // E.class, E#id, E[attr] etc. AND FindElements(); // take next el, #. etc off queue } } if (_evals.Count == 1) { return(_evals[0]); } return(new CombiningEvaluator.And(_evals)); }