/**
  * Processes the query.
  *
  * @param array $lexemes The lexemes
  * @returns xfCriterion
  */
 private function process(array $lexemes)
 {
     if (count($lexemes) == 0) {
         return new xfCriterionEmpty();
     }
     $this->builder = new xfCriterionBuilder($lexemes);
     $this->setupFiniteStateMachine();
     while ($lexeme = $this->builder->next()) {
         $this->fsm->process($lexeme->getType());
     }
     if ($this->fsm->getState() != self::ST_QUERY) {
         throw new xfParserException('Unexpected end of query.');
     }
     return $this->builder->getMaster();
 }
require 'parser/xfCriterionBuilder.class.php';
require 'parser/xfParserException.class.php';
require 'lexer/xfLexeme.class.php';
require 'criteria/xfCriterion.interface.php';
require 'criteria/xfCriteria.class.php';
require 'criteria/xfCriterionTerm.class.php';
require 'criteria/xfCriterionDecorator.class.php';
require 'criteria/xfCriterionRequired.class.php';
require 'criteria/xfCriterionBoost.class.php';
require 'criteria/xfCriterionEmpty.class.php';
$t = new lime_test(17, new lime_output_color());
$b = new xfCriterionBuilder(array(new xfLexeme('foo', 1, 10), new xfLexeme('bar', 2, 50)));
$t->isa_ok($b->next(), 'xfLexeme', '->next() returns a lexeme');
$t->is($b->next()->getLexeme(), 'bar', '->next() advances the pointer');
$t->is($b->next(), null, '->next() returns null when the pointer is out of bounds');
$b = new xfCriterionBuilder(array(new xfLexeme('foo', 1, 10), new xfLexeme('bar', 2, 50)));
$b->next();
$t->is($b->getLexeme()->getLexeme(), 'foo', '->getLexeme() returns the current lexeme');
$t->is($b->getLexeme(1)->getLexeme(), 'bar', '->getLexeme() returns the next lexeme');
$b->next();
$t->is($b->getLexeme(-1)->getLexeme(), 'foo', '->getLexeme() returns the previous lexeme');
try {
    $msg = '->getLexeme() fails if it is out of bounds.';
    $b->getLexeme(-10);
    $t->fail($msg);
} catch (Exception $e) {
    $t->pass($msg);
}
$t->is($b->getMaster()->toString(), 'EMPTY', '->getMaster() returns the master query');
$b->openBoolean();
try {