Skip to content

Commit 5ec7b0a

Browse files
committed
Use constant
1 parent a1b8c1d commit 5ec7b0a

2 files changed

Lines changed: 90 additions & 88 deletions

File tree

build.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
use SQLParser\Lexer;
66

77
$constants = '';
8+
$array = '';
89

910
foreach (Lexer::getKeywords() as $code => $id) {
11+
$array .= 'self::T_' . strtoupper($code) . " => true,\n";
1012
$constants .= 'const T_' . strtoupper($code) . ' = ' . var_export($code, true) . ";\n\n";
1113
}
1214

@@ -16,8 +18,8 @@
1618
1719
class ReservedWords
1820
{
19-
' . $constants . '
20-
public static $words = ' . var_export(Lexer::getKeywords(), true) . ';
21+
' . $constants ."
22+
public static \$words = [\n" . $array . '];
2123
}';
2224

2325

src/SQL/ReservedWords.php

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -201,91 +201,91 @@ class ReservedWords
201201
const T_WORK = 'work';
202202

203203
public static $words = [
204-
'add' => 44,
205-
'after' => 53,
206-
'all' => 55,
207-
'alter' => 35,
208-
'and' => 2,
209-
'as' => 49,
210-
'asc' => 79,
211-
'auto_increment' => 96,
212-
'begin' => 26,
213-
'between' => 98,
214-
'binary' => 99,
215-
'bitwise' => 21,
216-
'by' => 77,
217-
'case' => 100,
218-
'change' => 50,
219-
'collate' => 94,
220-
'column' => 51,
221-
'commit' => 33,
222-
'create' => 46,
223-
'default' => 42,
224-
'delete' => 85,
225-
'desc' => 78,
226-
'distinct' => 56,
227-
'distinctrow' => 57,
228-
'drop' => 37,
229-
'duplicate' => 90,
230-
'else' => 101,
231-
'end' => 34,
232-
'filter_pipe' => 22,
233-
'first' => 52,
234-
'from' => 66,
235-
'glob' => 8,
236-
'group' => 82,
237-
'having' => 83,
238-
'high_priority' => 58,
239-
'in' => 14,
240-
'index' => 40,
241-
'inner' => 69,
242-
'insert' => 87,
243-
'interval' => 104,
244-
'into' => 89,
245-
'is' => 97,
246-
'join' => 68,
247-
'key' => 39,
248-
'left' => 70,
249-
'like' => 7,
250-
'limit' => 80,
251-
'lt' => 12,
252-
'modify' => 43,
253-
'natural' => 72,
254-
'not' => 3,
255-
'null' => 95,
256-
'offset' => 81,
257-
'on' => 47,
258-
'or' => 1,
259-
'order' => 76,
260-
'outer' => 73,
261-
'pipe' => 20,
262-
'primary' => 38,
263-
'release' => 28,
264-
'rename' => 45,
265-
'rollback' => 29,
266-
'rt_ight' => 71,
267-
'savepoint' => 27,
268-
'select' => 54,
269-
'set' => 41,
270-
'sql_big_result' => 61,
271-
'sql_buffer_result' => 64,
272-
'sql_cache' => 62,
273-
'sql_calc_found_rows' => 63,
274-
'sql_no_cache' => 65,
275-
'sql_small_result' => 60,
276-
'straight_join' => 59,
277-
'table' => 36,
278-
'then' => 103,
279-
'to' => 30,
280-
'transaction' => 31,
281-
'unique' => 48,
282-
'unsigned' => 93,
283-
'update' => 86,
284-
'using' => 74,
285-
'values' => 84,
286-
'view' => 91,
287-
'when' => 102,
288-
'where' => 75,
289-
'work' => 32,
204+
self::T_ADD => true,
205+
self::T_AFTER => true,
206+
self::T_ALL => true,
207+
self::T_ALTER => true,
208+
self::T_AND => true,
209+
self::T_AS => true,
210+
self::T_ASC => true,
211+
self::T_AUTO_INCREMENT => true,
212+
self::T_BEGIN => true,
213+
self::T_BETWEEN => true,
214+
self::T_BINARY => true,
215+
self::T_BITWISE => true,
216+
self::T_BY => true,
217+
self::T_CASE => true,
218+
self::T_CHANGE => true,
219+
self::T_COLLATE => true,
220+
self::T_COLUMN => true,
221+
self::T_COMMIT => true,
222+
self::T_CREATE => true,
223+
self::T_DEFAULT => true,
224+
self::T_DELETE => true,
225+
self::T_DESC => true,
226+
self::T_DISTINCT => true,
227+
self::T_DISTINCTROW => true,
228+
self::T_DROP => true,
229+
self::T_DUPLICATE => true,
230+
self::T_ELSE => true,
231+
self::T_END => true,
232+
self::T_FILTER_PIPE => true,
233+
self::T_FIRST => true,
234+
self::T_FROM => true,
235+
self::T_GLOB => true,
236+
self::T_GROUP => true,
237+
self::T_HAVING => true,
238+
self::T_HIGH_PRIORITY => true,
239+
self::T_IN => true,
240+
self::T_INDEX => true,
241+
self::T_INNER => true,
242+
self::T_INSERT => true,
243+
self::T_INTERVAL => true,
244+
self::T_INTO => true,
245+
self::T_IS => true,
246+
self::T_JOIN => true,
247+
self::T_KEY => true,
248+
self::T_LEFT => true,
249+
self::T_LIKE => true,
250+
self::T_LIMIT => true,
251+
self::T_LT => true,
252+
self::T_MODIFY => true,
253+
self::T_NATURAL => true,
254+
self::T_NOT => true,
255+
self::T_NULL => true,
256+
self::T_OFFSET => true,
257+
self::T_ON => true,
258+
self::T_OR => true,
259+
self::T_ORDER => true,
260+
self::T_OUTER => true,
261+
self::T_PIPE => true,
262+
self::T_PRIMARY => true,
263+
self::T_RELEASE => true,
264+
self::T_RENAME => true,
265+
self::T_ROLLBACK => true,
266+
self::T_RT_IGHT => true,
267+
self::T_SAVEPOINT => true,
268+
self::T_SELECT => true,
269+
self::T_SET => true,
270+
self::T_SQL_BIG_RESULT => true,
271+
self::T_SQL_BUFFER_RESULT => true,
272+
self::T_SQL_CACHE => true,
273+
self::T_SQL_CALC_FOUND_ROWS => true,
274+
self::T_SQL_NO_CACHE => true,
275+
self::T_SQL_SMALL_RESULT => true,
276+
self::T_STRAIGHT_JOIN => true,
277+
self::T_TABLE => true,
278+
self::T_THEN => true,
279+
self::T_TO => true,
280+
self::T_TRANSACTION => true,
281+
self::T_UNIQUE => true,
282+
self::T_UNSIGNED => true,
283+
self::T_UPDATE => true,
284+
self::T_USING => true,
285+
self::T_VALUES => true,
286+
self::T_VIEW => true,
287+
self::T_WHEN => true,
288+
self::T_WHERE => true,
289+
self::T_WORK => true,
290290
];
291291
}

0 commit comments

Comments
 (0)