Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Nov 27, 2018
1 parent ef7968e commit 2d0b364
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
41 changes: 22 additions & 19 deletions src/Components/CaseExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
case 'END':
$state = 3; // end of CASE expression
++$list->idx;
break;
break 2;
default:
$parser->error('Unexpected keyword.', $token);
break;
break 2;
}
} else {
$ret->value = Expression::parse($parser, $list);
Expand All @@ -148,43 +148,46 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$new_value = Expression::parse($parser, $list);
$state = 2;
$ret->compare_values[] = $new_value;
break;
break;
case 'ELSE':
++$list->idx; // Skip 'ELSE'
$ret->else_result = Expression::parse($parser, $list);
$state = 0; // last clause of CASE expression
break;
break;
case 'END':
$state = 3; // end of CASE expression
++$list->idx;
break;
break 2;
default:
$parser->error('Unexpected keyword.', $token);
break;
break 2;
}
}
} else if ($token->type === Token::TYPE_KEYWORD) {
if ($token->keyword === 'THEN') {
} else {
if ($token->type === Token::TYPE_KEYWORD
&& $token->keyword === 'THEN'
) {
++$list->idx; // Skip 'THEN'
$new_result = Expression::parse($parser, $list);
$state = 0;
$ret->results[] = $new_result;
} else {
} elseif ($token->type === Token::TYPE_KEYWORD) {
$parser->error('Unexpected keyword.', $token);
break;
}
break;
}
} elseif ($state === 2) {
if ($type === 0) {
if ($token->type === Token::TYPE_KEYWORD) {
if ($token->keyword === 'THEN') {
++$list->idx; // Skip 'THEN'
$new_result = Expression::parse($parser, $list);
$ret->results[] = $new_result;
$state = 1;
} else {
$parser->error('Unexpected keyword.', $token);
}
if ($token->type === Token::TYPE_KEYWORD
&& $token->keyword === 'THEN'
) {
++$list->idx; // Skip 'THEN'
$new_result = Expression::parse($parser, $list);
$ret->results[] = $new_result;
$state = 1;
} elseif ($token->type === Token::TYPE_KEYWORD) {
$parser->error('Unexpected keyword.', $token);
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/JoinKeyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$state = 1;
} else {
/* Next clause is starting */
break;
break 2;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Statements/CreateStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public function parse(Parser $parser, TokensList $list)
// This is used instead of `++$brackets` because,
// initially, `$brackets` is `false` cannot be
// incremented.
++$brackets;
$brackets = $brackets + 1;
} elseif ($token->value === ')') {
--$brackets;
}
Expand Down

0 comments on commit 2d0b364

Please sign in to comment.