summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Lexer.php33
-rw-r--r--src/Statements/CreateStatement.php16
2 files changed, 23 insertions, 26 deletions
diff --git a/src/Lexer.php b/src/Lexer.php
index 17b3f35..d091221 100644
--- a/src/Lexer.php
+++ b/src/Lexer.php
@@ -516,11 +516,8 @@ class Lexer
$state = 1;
for (; $this->last < $this->len; ++$this->last) {
if ($state === 1) {
- if ($this->str[$this->last] === '+') {
- // Do nothing.
- } elseif ($this->str[$this->last] === '-') {
+ if ($this->str[$this->last] === '-') {
$flags |= Token::FLAG_NUMBER_NEGATIVE;
- // Do nothing.
} elseif (($this->str[$this->last] === '0') && ($this->last + 1 < $this->len)
&& (($this->str[$this->last + 1] === 'x') || ($this->str[$this->last + 1] === 'X'))
) {
@@ -530,36 +527,33 @@ class Lexer
$state = 3;
} elseif ($this->str[$this->last] === '.') {
$state = 4;
- } else {
+ } elseif ($this->str[$this->last] !== '+') {
+ // `+` is a valid character in a number.
break;
}
} elseif ($state === 2) {
$flags |= Token::FLAG_NUMBER_HEX;
- if ((($this->str[$this->last] >= '0') && ($this->str[$this->last] <= '9'))
+ if (!((($this->str[$this->last] >= '0') && ($this->str[$this->last] <= '9'))
|| (($this->str[$this->last] >= 'A') && ($this->str[$this->last] <= 'F'))
- || (($this->str[$this->last] >= 'a') && ($this->str[$this->last] <= 'f'))
+ || (($this->str[$this->last] >= 'a') && ($this->str[$this->last] <= 'f')))
) {
- // Do nothing.
- } else {
break;
}
} elseif ($state === 3) {
- if (($this->str[$this->last] >= '0') && ($this->str[$this->last] <= '9')) {
- // Do nothing.
- } elseif ($this->str[$this->last] === '.') {
+ if ($this->str[$this->last] === '.') {
$state = 4;
} elseif (($this->str[$this->last] === 'e') || ($this->str[$this->last] === 'E')) {
$state = 5;
- } else {
+ } elseif (($this->str[$this->last] < '0') || ($this->str[$this->last] > '9')) {
+ // Just digits and `.`, `e` and `E` are valid characters.
break;
}
} elseif ($state === 4) {
$flags |= Token::FLAG_NUMBER_FLOAT;
- if (($this->str[$this->last] >= '0') && ($this->str[$this->last] <= '9')) {
- // Do nothing.
- } elseif (($this->str[$this->last] === 'e') || ($this->str[$this->last] === 'E')) {
+ if (($this->str[$this->last] === 'e') || ($this->str[$this->last] === 'E')) {
$state = 5;
- } else {
+ } elseif (($this->str[$this->last] < '0') || ($this->str[$this->last] > '9')) {
+ // Just digits, `e` and `E` are valid characters.
break;
}
} elseif ($state === 5) {
@@ -572,9 +566,8 @@ class Lexer
break;
}
} elseif ($state === 6) {
- if (($this->str[$this->last] >= '0') && ($this->str[$this->last] <= '9')) {
- // Do nothing.
- } else {
+ if (($this->str[$this->last] < '0') || ($this->str[$this->last] > '9')) {
+ // Just digits are valid characters.
break;
}
}
diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php
index 6084678..8475448 100644
--- a/src/Statements/CreateStatement.php
+++ b/src/Statements/CreateStatement.php
@@ -215,6 +215,14 @@ class CreateStatement extends Statement
*/
public function build()
{
+ $fields = '';
+ if (!empty($this->fields)) {
+ if (is_array($this->fields)) {
+ $fields = FieldDefinition::build($this->fields) . ' ';
+ } elseif ($this->fields instanceof ArrayObj) {
+ $fields = ArrayObj::build($this->fields);
+ }
+ }
if ($this->options->has('DATABASE')) {
return 'CREATE '
. OptionsArray::build($this->options) . ' '
@@ -224,17 +232,13 @@ class CreateStatement extends Statement
return 'CREATE '
. OptionsArray::build($this->options) . ' '
. Expression::build($this->name) . ' '
- . FieldDefinition::build($this->fields) . ' '
+ . $fields
. OptionsArray::build($this->entityOptions);
} elseif ($this->options->has('VIEW')) {
- $tmp = '';
- if (!empty($this->fields)) {
- $tmp = ArrayObj::build($this->fields);
- }
return 'CREATE '
. OptionsArray::build($this->options) . ' '
. Expression::build($this->name) . ' '
- . $tmp . ' AS ' . TokensList::build($this->body) . ' '
+ . $fields . ' AS ' . TokensList::build($this->body) . ' '
. OptionsArray::build($this->entityOptions);
} elseif ($this->options->has('TRIGGER')) {
return 'CREATE '