summaryrefslogtreecommitdiffstats
path: root/src/Lexer.php
diff options
context:
space:
mode:
authorDan Ungureanu <udan1107@gmail.com>2015-07-03 21:18:10 +0300
committerDan Ungureanu <udan1107@gmail.com>2015-07-04 23:41:52 +0300
commitb3eff80030f9bd6d90e65360eb89e18a1be298b2 (patch)
treedb420fef27f24856f4cfaeee008104fdfcb77942 /src/Lexer.php
parent4dabcc2ae266c022e44294bfbe3344b05e66e266 (diff)
downloadsql-parser-b3eff80030f9bd6d90e65360eb89e18a1be298b2.zip
sql-parser-b3eff80030f9bd6d90e65360eb89e18a1be298b2.tar.gz
sql-parser-b3eff80030f9bd6d90e65360eb89e18a1be298b2.tar.bz2
The context depends on the SQL mode.
Implemented a few more builders. Improved some fragments and statement types. Fixed the noAlias option in FieldFragment. Reordered CREATE statements's options. Updated contexts definitions. Fixed typos. Improved tests.
Diffstat (limited to 'src/Lexer.php')
-rw-r--r--src/Lexer.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Lexer.php b/src/Lexer.php
index 0d0862d..01d41d8 100644
--- a/src/Lexer.php
+++ b/src/Lexer.php
@@ -290,7 +290,25 @@ class Lexer
*/
$iEnd = $this->last;
+ /**
+ * Whether last parsed character is a whitespace.
+ * @var bool
+ */
+ $lastSpace = false;
+
for ($j = 1; $j < Context::KEYWORD_MAX_LENGTH && $this->last < $this->len; ++$j, ++$this->last) {
+ // Composed keywords shouldn't have more than one whitespace between
+ // keywords.
+ if (Context::isWhitespace($this->str[$this->last])) {
+ if ($lastSpace) {
+ --$j; // The size of the keyword didn't increase.
+ continue;
+ } else {
+ $lastSpace = true;
+ }
+ } else {
+ $lastSpace = false;
+ }
$token .= $this->str[$this->last];
if (($this->last + 1 === $this->len) || (Context::isSeparator($this->str[$this->last + 1]))) {
if (($flags = Context::isKeyword($token))) {