value; if ($value) { $start = $node->column; $end = $start + drupal_strlen($value); if ($this->consumedIndex < $start) { $error = drupal_substr($this->query, $this->consumedIndex, $start - $this->consumedIndex); if (drupal_strlen($error) > 0) { // there is text not recognized by the parser. if (trim($error)) { // we have real content missing -> mark it red $this->result .= ''. $error .''; } else { // let's just add a space $this->addSpace(); } } } $this->consumedIndex = $end; $this->result .= ''. $value .''; } } private function dumpWithSpace($node) { $this->result .= ' '; $this->dump($node); $this->result .= ' '; } private function dumpRemaining() { $error = drupal_substr($this->query, $this->consumedIndex); if ($error != "") { $this->result .= ''. $error .''; } } private function addSpace() { $this->result .= ' '; } function error($tqlASTParts, $originalQuery) { // init the state $this->consumedIndex = 0; $this->result = ""; $this->query = $originalQuery; foreach ($tqlASTParts as $ast) { $ast->accept ($this); } $this->dumpRemaining(); return $this->result; } /* * Visitor functions */ function printAndAccept($node) { if ($node->previous) { $this->dump($node->previous); } $node->accept($this); if ($node->next) { $this->dump($node->next); } } function visitIdentifier($tqlIdentifier) { $this->dump ($tqlIdentifier); } function visitUnaryOperation($tqlUnaryOperation) { // switch to operation visitor // check for null as operand can be null in error case if ($tqlUnaryOperation->operand) { return $tqlUnaryOperation->acceptOperation($this); } } function visitBinaryOperation($tqlBinaryOperation) { // switch to operation visitor return $tqlBinaryOperation->acceptOperation($this); } function visitNot($tqlNot) { $this->dump ($tqlNot); $operand = $tqlNot->operand->accept($this); } function visitAnd($tqlAnd) { $left = $this->printAndAccept($tqlAnd->left); $this->dump($tqlAnd); $right = $this->printAndAccept($tqlAnd->right); } function visitOr($tqlOr) { $left = $this->printAndAccept($tqlOr->left); $this->dump($tqlOr); $right = $this->printAndAccept($tqlOr->right); } function visitXor($tqlXor) { $left = $tqlXor->left->accept($this); $this->dump($tqlXor); $right = $tqlXor->right->accept($this); } }