diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Lexer.php | 26 | ||||
-rw-r--r-- | src/Utils/Query.php | 4 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/Lexer.php b/src/Lexer.php index 69c1ff2..82385e3 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -515,15 +515,39 @@ namespace SqlParser { $token .= $this->str[$this->last]; if (Context::isComment($token)) { $flags = Token::FLAG_COMMENT_C; + + // This comment already ended. It may be a part of a + // previous MySQL specific command. + if ($token === '*/') { + return new Token($token, Token::TYPE_COMMENT, $flags); + } + + // Checking if this is a MySQL-specific command. if (($this->last + 1 < $this->len) && ($this->str[$this->last + 1] === '!')) { - // It is a MySQL-specific command. $flags |= Token::FLAG_COMMENT_MYSQL_CMD; + $token .= $this->str[++$this->last]; + + while ((++$this->last < $this->len) + && ('0' <= $this->str[$this->last]) + && ($this->str[$this->last] <= '9') + ) { + $token .= $this->str[$this->last]; + } + --$this->last; + + // We split this comment and parse only its beginning + // here. + return new Token($token, Token::TYPE_COMMENT, $flags); } + + // Parsing the comment. while ((++$this->last < $this->len) && (($this->str[$this->last - 1] !== '*') || ($this->str[$this->last] !== '/')) ) { $token .= $this->str[$this->last]; } + + // Adding the ending. if ($this->last < $this->len) { $token .= $this->str[$this->last]; } diff --git a/src/Utils/Query.php b/src/Utils/Query.php index 41e99d1..86325ed 100644 --- a/src/Utils/Query.php +++ b/src/Utils/Query.php @@ -743,9 +743,7 @@ class Query for ($list->idx = 0; $list->idx < $list->count; ++$list->idx) { $token = $list->tokens[$list->idx]; - if (($token->type === Token::TYPE_COMMENT) - && (!($token->flags & Token::FLAG_COMMENT_MYSQL_CMD)) - ) { + if ($token->type === Token::TYPE_COMMENT) { continue; } |