/** * @param Lexer $lexer * @param char $char */ public function input(Lexer $lexer, $char) { if ($this->escaping) { $this->buffer .= $char; $this->escaping = false; } else { if ($char == "'") { $lexer->pushOperand(new TokenLiteral($this->buffer)); $this->closed = true; } else { if ($char == '\\') { $this->escaping = true; } else { if ($this->closed) { if ($char == ',') { $lexer->incrementLastFunctionArity(); $lexer->setStateEmpty(); } else { if ($char == ')') { $lexer->closeParenthesis(); } else { if (self::isBlank($char)) { } else { if ($char == '+' || $char == '-') { $lexer->pushOperator(new TokenPlusMinus($char)); } else { if ($char == '=' || $char == '!') { $lexer->setStateComparison($char); } else { if ($char == '*') { $lexer->pushOperator(new TokenMul()); } else { if ($char == ']') { $lexer->closeSquareBracket(); } else { $this->throwError($lexer, $char); } } } } } } } } else { $this->buffer .= $char; } } } } }
/** * @param Lexer $lexer * @param char $char */ public function input(Lexer $lexer, $char) { if ($char == "'") { $lexer->setStateString(); } else { if (self::isAlpha($char)) { $lexer->setStateSymbol($char); } else { if ($char == '-' || $char == '+') { $lexer->pushOperator(new TokenUnarySign($char)); } else { if (self::isDigit($char)) { $lexer->setStateInteger($char); } else { if ($char == '(') { $lexer->pushOperator(new TokenLParen()); } else { if ($char == '*') { $lexer->pushOperator(new TokenMul()); } else { if ($char == ')') { $lexer->closeParenthesis(); } else { if ($char == ',') { $lexer->incrementLastFunctionArity(); } else { if ($char == '/') { $lexer->pushPath(new PathElementRoot()); } else { if ($char == '.') { $lexer->setStateDot(); } else { if (self::isBlank($char)) { } else { $this->throwError($lexer, $char); } } } } } } } } } } } }
/** * @param Lexer $lexer * @param char $char */ public function input(Lexer $lexer, $char) { if (self::isBlank($char)) { } else { if ($char == '+' || $char == '-') { $lexer->pushOperator(new TokenPlusMinus($char)); } else { if ($char == '*') { $lexer->pushOperator(new TokenMul()); } else { if ($char == '!') { $lexer->setStateComparison($char); } else { if ($char == '=') { $lexer->setStateComparison($char); } else { if (self::isAlpha($char)) { $lexer->setStateSymbol($char); } else { if ($char == ')') { $lexer->closeParenthesis(); } else { if ($char == ']') { $lexer->closeSquareBracket(); } else { if ($char == ',') { $lexer->incrementLastFunctionArity(); } else { $this->throwError($lexer, $char); } } } } } } } } } }
/** * @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); } } } } } } }
/** * @param Lexer $lexer * @param string $char */ public function input(Lexer $lexer, $char) { //Valid inputs while in state Path are: //- any alphanum if not closed, //- opening [ if not closed and separated, //- slash if not closed and not separated, //- opening ( if not separated, //- closing ) always //- , (comma) always if ($char == ',') { if (!$this->closedSubpath && !$this->closed) { $lexer->pushPathElement($this->buffer); } $lexer->incrementLastFunctionArity(); } else { if ($char == ')') { if (!$this->closedSubpath && !$this->closed) { $lexer->pushPathElement($this->buffer); } $lexer->closeParenthesis(); } else { if ($char == '[') { if (!$this->closed && $this->separated && !$this->closedSubpath) { $lexer->pushOperator(new TokenLBracket()); } else { $this->throwError($lexer, $char); } } else { if ($char == ']') { $lexer->pushPathElement($this->buffer); $lexer->closeSquareBracket(); } else { if ($char == '/') { if (!$this->separated) { $this->separated = true; if (!$this->closed && !$this->closedSubpath) { $lexer->pushPathElement($this->buffer); } $this->closed = false; $this->buffer = ''; $this->closedSubpath = false; } else { $this->throwError($lexer, $char); } } else { if (self::isAlphaNum($char)) { if (!$this->closedSubpath) { $this->buffer .= $char; $this->separated = false; } else { $this->throwError($lexer, $char); } } else { if (self::isBlank($char)) { $this->closed = true; if (!$this->closedSubpath) { $lexer->pushPathElement($this->buffer); } $lexer->setStateClosedExpression(); } else { if ($char == '(' && !$this->separated) { $lexer->setStateFunction($this->buffer); } else { if ($char == '=' || $char == '!') { $this->closed = true; if (!$this->closedSubpath) { $lexer->pushPathElement($this->buffer); } $lexer->setStateComparison($char); } else { if ($char == '+' || $char == '-') { $this->closed = true; if (!$this->closedSubpath) { $lexer->pushPathElement($this->buffer); } $lexer->pushOperator(new TokenPlusMinus($char)); } else { $this->throwError($lexer, $char); } } } } } } } } } } }