Пример #1
0
 /**
  * @param Lexer $lexer
  * @param char $char
  */
 public function input(Lexer $lexer, $char)
 {
     //Valid inputs in this state are:
     // - Slash (/) means that we are talking about the Path Element: Dot,
     // - any digit, means that we are talking about a Decimal,
     // - dot, means that we are talking about the Path Element: Parent.
     // - comma, means that the current argument of a function is the Current path.
     //TODO: and also closing parenthesis, closing square bracket, blank.
     if ($char == '/') {
         $lexer->pushPath(new PathElementCurrent());
     } else {
         if (self::isDigit($char)) {
             $lexer->setStateDecimal('0.' . $char);
         } else {
             if ($char == '.') {
                 $lexer->setStateDotdot();
             } else {
                 if ($char == ',') {
                     $lexer->pushOperand(new TokenPath(new PathElementCurrent()));
                     $lexer->incrementLastFunctionArity();
                 } else {
                     if ($char == ')') {
                         $lexer->pushOperand(new TokenPath(new PathElementCurrent()));
                         $lexer->closeParenthesis();
                     } else {
                         if (self::isBlank($char)) {
                             $lexer->pushPath(new PathElementCurrent());
                             $lexer->setStateClosedExpression();
                         } else {
                             $this->throwError($lexer, $char);
                         }
                     }
                 }
             }
         }
     }
 }