summaryrefslogtreecommitdiffstats
path: root/src/Fragments/SetKeyword.php
diff options
context:
space:
mode:
authorDan Ungureanu <udan1107@gmail.com>2015-07-10 01:45:45 +0300
committerDan Ungureanu <udan1107@gmail.com>2015-07-10 03:47:19 +0300
commit527842708bf44fe2bb4d17a97203cec01b860960 (patch)
tree9eb52c23199199b721b5412e1c16d9129d624e52 /src/Fragments/SetKeyword.php
parent7c925b68763e86be121664575632c9261d380821 (diff)
downloadsql-parser-527842708bf44fe2bb4d17a97203cec01b860960.zip
sql-parser-527842708bf44fe2bb4d17a97203cec01b860960.tar.gz
sql-parser-527842708bf44fe2bb4d17a97203cec01b860960.tar.bz2
Mass renaming. Using 'component' instead of 'fragment'.
Diffstat (limited to 'src/Fragments/SetKeyword.php')
-rw-r--r--src/Fragments/SetKeyword.php122
1 files changed, 0 insertions, 122 deletions
diff --git a/src/Fragments/SetKeyword.php b/src/Fragments/SetKeyword.php
deleted file mode 100644
index d9e0871..0000000
--- a/src/Fragments/SetKeyword.php
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-/**
- * `SET` keyword parser.
- *
- * @package SqlParser
- * @subpackage Fragments
- */
-namespace SqlParser\Fragments;
-
-use SqlParser\Fragment;
-use SqlParser\Parser;
-use SqlParser\Token;
-use SqlParser\TokensList;
-
-/**
- * `SET` keyword parser.
- *
- * @category Keywords
- * @package SqlParser
- * @subpackage Fragments
- * @author Dan Ungureanu <udan1107@gmail.com>
- * @license http://opensource.org/licenses/GPL-2.0 GNU Public License
- */
-class SetKeyword extends Fragment
-{
-
- /**
- * The name of the column that is being updated.
- *
- * @var string
- */
- public $column;
-
- /**
- * The new value.
- *
- * @var string
- */
- public $value;
-
- /**
- * @param Parser $parser The parser that serves as context.
- * @param TokensList $list The list of tokens that are being parsed.
- * @param array $options Parameters for parsing.
- *
- * @return SetKeyword[]
- */
- public static function parse(Parser $parser, TokensList $list, array $options = array())
- {
- $ret = array();
-
- $expr = new SetKeyword();
-
- /**
- * The state of the parser.
- *
- * Below are the states of the parser.
- *
- * 0 -------------------[ field name ]--------------------> 1
- *
- * 1 ------------------------[ , ]------------------------> 0
- * 1 ----------------------[ value ]----------------------> 1
- *
- * @var int
- */
- $state = 0;
-
- for (; $list->idx < $list->count; ++$list->idx) {
- /**
- * Token parsed at this moment.
- * @var Token $token
- */
- $token = $list->tokens[$list->idx];
-
- // End of statement.
- if ($token->type === Token::TYPE_DELIMITER) {
- break;
- }
-
- // Skipping whitespaces and comments.
- if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) {
- continue;
- }
-
- // No keyword is expected.
- if (($token->type === Token::TYPE_KEYWORD) && ($token->flags & Token::FLAG_KEYWORD_RESERVED)) {
- break;
- }
-
- if ($token->type === Token::TYPE_OPERATOR) {
- if ($token->value === ',') {
- $expr->column = trim($expr->column);
- $expr->value = trim($expr->value);
- $ret[] = $expr;
- $expr = new SetKeyword();
- $state = 0;
- continue;
- } elseif ($token->value === '=') {
- $state = 1;
- continue;
- }
- }
-
- if ($state === 0) {
- $expr->column .= $token->token;
- } else { // } else if ($state === 1) {
- $expr->value .= $token->token;
- }
- }
-
- // Last iteration was not saved.
- if (!empty($expr->column)) {
- $expr->column = trim($expr->column);
- $expr->value = trim($expr->value);
- $ret[] = $expr;
- }
-
- --$list->idx;
- return $ret;
- }
-}