1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33:
34: class Text_Highlighter_MYSQL extends Text_Highlighter
35: {
36: var $_language = 'mysql';
37:
38: 39: 40: 41: 42: 43:
44: function __construct($options=array())
45: {
46:
47: $this->_options = $options;
48: $this->_regs = array (
49: -1 => '/((?i)`)|((?i)\\/\\*)|((?i)(#|--\\s).*)|((?i)[a-z_]\\w*(?=\\s*\\())|((?i)[a-z_]\\w*)|((?i)")|((?i)\\()|((?i)\')|((?i)((\\d+|((\\d*\\.\\d+)|(\\d+\\.\\d*)))[eE][+-]?\\d+))|((?i)(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)\\d+l?|\\b0l?\\b)|((?i)0[xX][\\da-f]+l?)/',
50: 0 => '//',
51: 1 => '//',
52: 2 => '/((?i)\\\\.)/',
53: 3 => '/((?i)`)|((?i)\\/\\*)|((?i)(#|--\\s).*)|((?i)[a-z_]\\w*(?=\\s*\\())|((?i)[a-z_]\\w*)|((?i)")|((?i)\\()|((?i)\')|((?i)((\\d+|((\\d*\\.\\d+)|(\\d+\\.\\d*)))[eE][+-]?\\d+))|((?i)(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)\\d+l?|\\b0l?\\b)|((?i)0[xX][\\da-f]+l?)/',
54: 4 => '/((?i)\\\\.)/',
55: );
56: $this->_counts = array (
57: -1 =>
58: array (
59: 0 => 0,
60: 1 => 0,
61: 2 => 1,
62: 3 => 0,
63: 4 => 0,
64: 5 => 0,
65: 6 => 0,
66: 7 => 0,
67: 8 => 5,
68: 9 => 2,
69: 10 => 0,
70: 11 => 0,
71: ),
72: 0 =>
73: array (
74: ),
75: 1 =>
76: array (
77: ),
78: 2 =>
79: array (
80: 0 => 0,
81: ),
82: 3 =>
83: array (
84: 0 => 0,
85: 1 => 0,
86: 2 => 1,
87: 3 => 0,
88: 4 => 0,
89: 5 => 0,
90: 6 => 0,
91: 7 => 0,
92: 8 => 5,
93: 9 => 2,
94: 10 => 0,
95: 11 => 0,
96: ),
97: 4 =>
98: array (
99: 0 => 0,
100: ),
101: );
102: $this->_delim = array (
103: -1 =>
104: array (
105: 0 => 'quotes',
106: 1 => 'comment',
107: 2 => '',
108: 3 => '',
109: 4 => '',
110: 5 => 'quotes',
111: 6 => 'brackets',
112: 7 => 'quotes',
113: 8 => '',
114: 9 => '',
115: 10 => '',
116: 11 => '',
117: ),
118: 0 =>
119: array (
120: ),
121: 1 =>
122: array (
123: ),
124: 2 =>
125: array (
126: 0 => '',
127: ),
128: 3 =>
129: array (
130: 0 => 'quotes',
131: 1 => 'comment',
132: 2 => '',
133: 3 => '',
134: 4 => '',
135: 5 => 'quotes',
136: 6 => 'brackets',
137: 7 => 'quotes',
138: 8 => '',
139: 9 => '',
140: 10 => '',
141: 11 => '',
142: ),
143: 4 =>
144: array (
145: 0 => '',
146: ),
147: );
148: $this->_inner = array (
149: -1 =>
150: array (
151: 0 => 'identifier',
152: 1 => 'comment',
153: 2 => 'comment',
154: 3 => 'identifier',
155: 4 => 'identifier',
156: 5 => 'string',
157: 6 => 'code',
158: 7 => 'string',
159: 8 => 'number',
160: 9 => 'number',
161: 10 => 'number',
162: 11 => 'number',
163: ),
164: 0 =>
165: array (
166: ),
167: 1 =>
168: array (
169: ),
170: 2 =>
171: array (
172: 0 => 'special',
173: ),
174: 3 =>
175: array (
176: 0 => 'identifier',
177: 1 => 'comment',
178: 2 => 'comment',
179: 3 => 'identifier',
180: 4 => 'identifier',
181: 5 => 'string',
182: 6 => 'code',
183: 7 => 'string',
184: 8 => 'number',
185: 9 => 'number',
186: 10 => 'number',
187: 11 => 'number',
188: ),
189: 4 =>
190: array (
191: 0 => 'special',
192: ),
193: );
194: $this->_end = array (
195: 0 => '/(?i)`/',
196: 1 => '/(?i)\\*\\//',
197: 2 => '/(?i)"/',
198: 3 => '/(?i)\\)/',
199: 4 => '/(?i)\'/',
200: );
201: $this->_states = array (
202: -1 =>
203: array (
204: 0 => 0,
205: 1 => 1,
206: 2 => -1,
207: 3 => -1,
208: 4 => -1,
209: 5 => 2,
210: 6 => 3,
211: 7 => 4,
212: 8 => -1,
213: 9 => -1,
214: 10 => -1,
215: 11 => -1,
216: ),
217: 0 =>
218: array (
219: ),
220: 1 =>
221: array (
222: ),
223: 2 =>
224: array (
225: 0 => -1,
226: ),
227: 3 =>
228: array (
229: 0 => 0,
230: 1 => 1,
231: 2 => -1,
232: 3 => -1,
233: 4 => -1,
234: 5 => 2,
235: 6 => 3,
236: 7 => 4,
237: 8 => -1,
238: 9 => -1,
239: 10 => -1,
240: 11 => -1,
241: ),
242: 4 =>
243: array (
244: 0 => -1,
245: ),
246: );
247: $this->_keywords = array (
248: -1 =>
249: array (
250: 0 => -1,
251: 1 => -1,
252: 2 =>
253: array (
254: ),
255: 3 =>
256: array (
257: 'function' => '/^((?i)abs|acos|adddate|ascii|asin|atan|atan2|avg|benchmark|bin|ceiling|char|coalesce|concat|conv|cos|cot|count|curdate|curtime|database|dayname|dayofmonth|dayofweek|dayofyear|decode|degrees|elt|encode|encrypt|exp|extract|field|floor|format|greatest|hex|hour|if|ifnull|insert|instr|interval|isnull|lcase|least|left|length|locate|log|log10|lower|lpad|ltrim|max|md5|mid|min|minute|mod|month|monthname|now|nullif|oct|ord|password|pi|position|pow|power|prepare|quarter|radians|rand|repeat|replace|reverse|right|round|rpad|rtrim|second|sign|sin|soundex|space|sqrt|std|stddev|strcmp|subdate|substring|sum|sysdate|tan|trim|truncate|ucase|upper|user|version|week|weekday|year)$/',
258: ),
259: 4 =>
260: array (
261: 'reserved' => '/^((?i)action|add|aggregate|all|alter|after|and|as|asc|avg|avg_row_length|auto_increment|between|bigint|bit|binary|blob|bool|both|by|cascade|case|char|character|change|check|checksum|column|columns|comment|constraint|create|cross|current_date|current_time|current_timestamp|data|database|databases|date|datetime|day|day_hour|day_minute|day_second|dayofmonth|dayofweek|dayofyear|dec|decimal|default|delayed|delay_key_write|delete|desc|describe|distinct|distinctrow|double|drop|end|else|escape|escaped|enclosed|enum|explain|exists|fields|file|first|float|float4|float8|flush|foreign|from|for|full|function|global|grant|grants|group|having|heap|high_priority|hour|hour_minute|hour_second|hosts|identified|ignore|in|index|infile|inner|insert|insert_id|int|integer|interval|int1|int2|int3|int4|int8|into|if|is|isam|join|key|keys|kill|last_insert_id|leading|left|length|like|lines|limit|load|local|lock|logs|long|longblob|longtext|low_priority|max|max_rows|match|mediumblob|mediumtext|mediumint|middleint|min_rows|minute|minute_second|modify|month|monthname|myisam|natural|numeric|no|not|null|on|optimize|option|optionally|or|order|outer|outfile|pack_keys|partial|password|precision|primary|procedure|process|processlist|privileges|read|real|references|reload|regexp|rename|replace|restrict|returns|revoke|rlike|row|rows|second|select|set|show|shutdown|smallint|soname|sql_big_tables|sql_big_selects|sql_low_priority_updates|sql_log_off|sql_log_update|sql_select_limit|sql_small_result|sql_big_result|sql_warnings|straight_join|starting|status|string|table|tables|temporary|terminated|text|then|time|timestamp|tinyblob|tinytext|tinyint|trailing|to|type|use|using|unique|unlock|unsigned|update|usage|values|varchar|variables|varying|varbinary|with|write|when|where|year|year_month|zerofill)$/',
262: ),
263: 5 => -1,
264: 6 => -1,
265: 7 => -1,
266: 8 =>
267: array (
268: ),
269: 9 =>
270: array (
271: ),
272: 10 =>
273: array (
274: ),
275: 11 =>
276: array (
277: ),
278: ),
279: 0 =>
280: array (
281: ),
282: 1 =>
283: array (
284: ),
285: 2 =>
286: array (
287: 0 =>
288: array (
289: ),
290: ),
291: 3 =>
292: array (
293: 0 => -1,
294: 1 => -1,
295: 2 =>
296: array (
297: ),
298: 3 =>
299: array (
300: 'function' => '/^((?i)abs|acos|adddate|ascii|asin|atan|atan2|avg|benchmark|bin|ceiling|char|coalesce|concat|conv|cos|cot|count|curdate|curtime|database|dayname|dayofmonth|dayofweek|dayofyear|decode|degrees|elt|encode|encrypt|exp|extract|field|floor|format|greatest|hex|hour|if|ifnull|insert|instr|interval|isnull|lcase|least|left|length|locate|log|log10|lower|lpad|ltrim|max|md5|mid|min|minute|mod|month|monthname|now|nullif|oct|ord|password|pi|position|pow|power|prepare|quarter|radians|rand|repeat|replace|reverse|right|round|rpad|rtrim|second|sign|sin|soundex|space|sqrt|std|stddev|strcmp|subdate|substring|sum|sysdate|tan|trim|truncate|ucase|upper|user|version|week|weekday|year)$/',
301: ),
302: 4 =>
303: array (
304: 'reserved' => '/^((?i)action|add|aggregate|all|alter|after|and|as|asc|avg|avg_row_length|auto_increment|between|bigint|bit|binary|blob|bool|both|by|cascade|case|char|character|change|check|checksum|column|columns|comment|constraint|create|cross|current_date|current_time|current_timestamp|data|database|databases|date|datetime|day|day_hour|day_minute|day_second|dayofmonth|dayofweek|dayofyear|dec|decimal|default|delayed|delay_key_write|delete|desc|describe|distinct|distinctrow|double|drop|end|else|escape|escaped|enclosed|enum|explain|exists|fields|file|first|float|float4|float8|flush|foreign|from|for|full|function|global|grant|grants|group|having|heap|high_priority|hour|hour_minute|hour_second|hosts|identified|ignore|in|index|infile|inner|insert|insert_id|int|integer|interval|int1|int2|int3|int4|int8|into|if|is|isam|join|key|keys|kill|last_insert_id|leading|left|length|like|lines|limit|load|local|lock|logs|long|longblob|longtext|low_priority|max|max_rows|match|mediumblob|mediumtext|mediumint|middleint|min_rows|minute|minute_second|modify|month|monthname|myisam|natural|numeric|no|not|null|on|optimize|option|optionally|or|order|outer|outfile|pack_keys|partial|password|precision|primary|procedure|process|processlist|privileges|read|real|references|reload|regexp|rename|replace|restrict|returns|revoke|rlike|row|rows|second|select|set|show|shutdown|smallint|soname|sql_big_tables|sql_big_selects|sql_low_priority_updates|sql_log_off|sql_log_update|sql_select_limit|sql_small_result|sql_big_result|sql_warnings|straight_join|starting|status|string|table|tables|temporary|terminated|text|then|time|timestamp|tinyblob|tinytext|tinyint|trailing|to|type|use|using|unique|unlock|unsigned|update|usage|values|varchar|variables|varying|varbinary|with|write|when|where|year|year_month|zerofill)$/',
305: ),
306: 5 => -1,
307: 6 => -1,
308: 7 => -1,
309: 8 =>
310: array (
311: ),
312: 9 =>
313: array (
314: ),
315: 10 =>
316: array (
317: ),
318: 11 =>
319: array (
320: ),
321: ),
322: 4 =>
323: array (
324: 0 =>
325: array (
326: ),
327: ),
328: );
329: $this->_parts = array (
330: 0 =>
331: array (
332: ),
333: 1 =>
334: array (
335: ),
336: 2 =>
337: array (
338: 0 => NULL,
339: ),
340: 3 =>
341: array (
342: 0 => NULL,
343: 1 => NULL,
344: 2 => NULL,
345: 3 => NULL,
346: 4 => NULL,
347: 5 => NULL,
348: 6 => NULL,
349: 7 => NULL,
350: 8 => NULL,
351: 9 => NULL,
352: 10 => NULL,
353: 11 => NULL,
354: ),
355: 4 =>
356: array (
357: 0 => NULL,
358: ),
359: );
360: $this->_subst = array (
361: -1 =>
362: array (
363: 0 => false,
364: 1 => false,
365: 2 => false,
366: 3 => false,
367: 4 => false,
368: 5 => false,
369: 6 => false,
370: 7 => false,
371: 8 => false,
372: 9 => false,
373: 10 => false,
374: 11 => false,
375: ),
376: 0 =>
377: array (
378: ),
379: 1 =>
380: array (
381: ),
382: 2 =>
383: array (
384: 0 => false,
385: ),
386: 3 =>
387: array (
388: 0 => false,
389: 1 => false,
390: 2 => false,
391: 3 => false,
392: 4 => false,
393: 5 => false,
394: 6 => false,
395: 7 => false,
396: 8 => false,
397: 9 => false,
398: 10 => false,
399: 11 => false,
400: ),
401: 4 =>
402: array (
403: 0 => false,
404: ),
405: );
406: $this->_conditions = array (
407: );
408: $this->_kwmap = array (
409: 'function' => 'reserved',
410: 'reserved' => 'reserved',
411: );
412: $this->_defClass = 'code';
413: $this->_checkDefines();
414: }
415:
416: }