Пример #1
0
 /**
  * ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
  *
  * @return string
  */
 public function ComparisonOperator()
 {
     switch ($this->_lexer->lookahead['value']) {
         case '=':
             $this->match(Lexer::T_EQUALS);
             return '=';
         case '<':
             $this->match(Lexer::T_LOWER_THAN);
             $operator = '<';
             if ($this->_lexer->isNextToken(Lexer::T_EQUALS)) {
                 $this->match(Lexer::T_EQUALS);
                 $operator .= '=';
             } else {
                 if ($this->_lexer->isNextToken(Lexer::T_GREATER_THAN)) {
                     $this->match(Lexer::T_GREATER_THAN);
                     $operator .= '>';
                 }
             }
             return $operator;
         case '>':
             $this->match(Lexer::T_GREATER_THAN);
             $operator = '>';
             if ($this->_lexer->isNextToken(Lexer::T_EQUALS)) {
                 $this->match(Lexer::T_EQUALS);
                 $operator .= '=';
             }
             return $operator;
         case '!':
             $this->match(Lexer::T_NEGATE);
             $this->match(Lexer::T_EQUALS);
             return '<>';
         default:
             $this->syntaxError('=, <, <=, <>, >, >=, !=');
     }
 }
Пример #2
0
 /**
  * LikeExpression ::= StringExpression ["NOT"] "LIKE" (string | input_parameter) ["ESCAPE" char]
  */
 public function _LikeExpression()
 {
     $stringExpr = $this->_StringExpression();
     $isNot = false;
     if ($this->_lexer->lookahead['type'] === Lexer::T_NOT) {
         $this->match(Lexer::T_NOT);
         $isNot = true;
     }
     $this->match(Lexer::T_LIKE);
     if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) {
         $this->match(Lexer::T_INPUT_PARAMETER);
         $stringPattern = new AST\InputParameter($this->_lexer->token['value']);
     } else {
         $this->match(Lexer::T_STRING);
         $stringPattern = $this->_lexer->token['value'];
     }
     $escapeChar = null;
     if ($this->_lexer->lookahead['type'] === Lexer::T_ESCAPE) {
         $this->match(Lexer::T_ESCAPE);
         $this->match(Lexer::T_STRING);
         $escapeChar = $this->_lexer->token['value'];
     }
     return new AST\LikeExpression($stringExpr, $stringPattern, $isNot, $escapeChar);
 }