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: 35:
36: class Text_Highlighter_SQL extends Text_Highlighter
37: {
38: var $_language = 'sql';
39:
40: 41: 42: 43: 44: 45:
46: function __construct($options=array())
47: {
48:
49: $this->_options = $options;
50: $this->_regs = array (
51: -1 => '/((?i)`)|((?i)\\/\\*)|((?i)(#|--\\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?)/',
52: 0 => '//',
53: 1 => '//',
54: 2 => '/((?i)\\\\.)/',
55: 3 => '/((?i)`)|((?i)\\/\\*)|((?i)(#|--\\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?)/',
56: 4 => '/((?i)\\\\.)/',
57: );
58: $this->_counts = array (
59: -1 =>
60: array (
61: 0 => 0,
62: 1 => 0,
63: 2 => 1,
64: 3 => 0,
65: 4 => 0,
66: 5 => 0,
67: 6 => 0,
68: 7 => 5,
69: 8 => 2,
70: 9 => 0,
71: 10 => 0,
72: ),
73: 0 =>
74: array (
75: ),
76: 1 =>
77: array (
78: ),
79: 2 =>
80: array (
81: 0 => 0,
82: ),
83: 3 =>
84: array (
85: 0 => 0,
86: 1 => 0,
87: 2 => 1,
88: 3 => 0,
89: 4 => 0,
90: 5 => 0,
91: 6 => 0,
92: 7 => 5,
93: 8 => 2,
94: 9 => 0,
95: 10 => 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 => 'quotes',
110: 5 => 'brackets',
111: 6 => 'quotes',
112: 7 => '',
113: 8 => '',
114: 9 => '',
115: 10 => '',
116: ),
117: 0 =>
118: array (
119: ),
120: 1 =>
121: array (
122: ),
123: 2 =>
124: array (
125: 0 => '',
126: ),
127: 3 =>
128: array (
129: 0 => 'quotes',
130: 1 => 'comment',
131: 2 => '',
132: 3 => '',
133: 4 => 'quotes',
134: 5 => 'brackets',
135: 6 => 'quotes',
136: 7 => '',
137: 8 => '',
138: 9 => '',
139: 10 => '',
140: ),
141: 4 =>
142: array (
143: 0 => '',
144: ),
145: );
146: $this->_inner = array (
147: -1 =>
148: array (
149: 0 => 'identifier',
150: 1 => 'comment',
151: 2 => 'comment',
152: 3 => 'identifier',
153: 4 => 'string',
154: 5 => 'code',
155: 6 => 'string',
156: 7 => 'number',
157: 8 => 'number',
158: 9 => 'number',
159: 10 => 'number',
160: ),
161: 0 =>
162: array (
163: ),
164: 1 =>
165: array (
166: ),
167: 2 =>
168: array (
169: 0 => 'special',
170: ),
171: 3 =>
172: array (
173: 0 => 'identifier',
174: 1 => 'comment',
175: 2 => 'comment',
176: 3 => 'identifier',
177: 4 => 'string',
178: 5 => 'code',
179: 6 => 'string',
180: 7 => 'number',
181: 8 => 'number',
182: 9 => 'number',
183: 10 => 'number',
184: ),
185: 4 =>
186: array (
187: 0 => 'special',
188: ),
189: );
190: $this->_end = array (
191: 0 => '/(?i)`/',
192: 1 => '/(?i)\\*\\//',
193: 2 => '/(?i)"/',
194: 3 => '/(?i)\\)/',
195: 4 => '/(?i)\'/',
196: );
197: $this->_states = array (
198: -1 =>
199: array (
200: 0 => 0,
201: 1 => 1,
202: 2 => -1,
203: 3 => -1,
204: 4 => 2,
205: 5 => 3,
206: 6 => 4,
207: 7 => -1,
208: 8 => -1,
209: 9 => -1,
210: 10 => -1,
211: ),
212: 0 =>
213: array (
214: ),
215: 1 =>
216: array (
217: ),
218: 2 =>
219: array (
220: 0 => -1,
221: ),
222: 3 =>
223: array (
224: 0 => 0,
225: 1 => 1,
226: 2 => -1,
227: 3 => -1,
228: 4 => 2,
229: 5 => 3,
230: 6 => 4,
231: 7 => -1,
232: 8 => -1,
233: 9 => -1,
234: 10 => -1,
235: ),
236: 4 =>
237: array (
238: 0 => -1,
239: ),
240: );
241: $this->_keywords = array (
242: -1 =>
243: array (
244: 0 => -1,
245: 1 => -1,
246: 2 =>
247: array (
248: ),
249: 3 =>
250: array (
251: 'reserved' => '/^((?i)absolute|action|add|admin|after|aggregate|alias|all|allocate|alter|and|any|are|array|as|asc|assertion|at|authorization|before|begin|binary|bit|blob|boolean|both|breadth|by|call|cascade|cascaded|case|cast|catalog|char|character|check|class|clob|close|collate|collation|column|commit|completion|connect|connection|constraint|constraints|constructor|continue|corresponding|create|cross|cube|current|current_date|current_path|current_role|current_time|current_timestamp|current_user|cursor|cycle|data|date|day|deallocate|dec|decimal|declare|default|deferrable|deferred|delete|depth|deref|desc|describe|descriptor|destroy|destructor|deterministic|diagnostics|dictionary|disconnect|distinct|domain|double|drop|dynamic|each|else|end|end-exec|equals|escape|every|except|exception|exec|execute|external|false|fetch|first|float|for|foreign|found|free|from|full|function|general|get|global|go|goto|grant|group|grouping|having|host|hour|identity|ignore|immediate|in|indicator|initialize|initially|inner|inout|input|insert|int|integer|intersect|interval|into|is|isolation|iterate|join|key|language|large|last|lateral|leading|left|less|level|like|limit|local|localtime|localtimestamp|locator|map|match|minute|modifies|modify|module|month|names|national|natural|nchar|nclob|new|next|no|none|not|null|numeric|object|of|off|old|on|only|open|operation|option|or|order|ordinality|out|outer|output|pad|parameter|parameters|partial|path|postfix|precision|prefix|preorder|prepare|preserve|primary|prior|privileges|procedure|public|read|reads|real|recursive|ref|references|referencing|relative|restrict|result|return|returns|revoke|right|role|rollback|rollup|routine|row|rows|savepoint|schema|scope|scroll|search|second|section|select|sequence|session|session_user|set|sets|size|smallint|some|space|specific|specifictype|sql|sqlexception|sqlstate|sqlwarning|start|state|statement|static|structure|system_user|table|temporary|terminate|than|then|time|timestamp|timezone_hour|timezone_minute|to|trailing|transaction|translation|treat|trigger|true|under|union|unique|unknown|unnest|update|usage|user|using|value|values|varchar|variable|varying|view|when|whenever|where|with|without|work|write|year|zone)$/',
252: 'keyword' => '/^((?i)abs|ada|asensitive|assignment|asymmetric|atomic|avg|between|bitvar|bit_length|c|called|cardinality|catalog_name|chain|character_length|character_set_catalog|character_set_name|character_set_schema|char_length|checked|class_origin|coalesce|cobol|collation_catalog|collation_name|collation_schema|column_name|command_function|command_function_code|committed|condition_number|connection_name|constraint_catalog|constraint_name|constraint_schema|contains|convert|count|cursor_name|datetime_interval_code|datetime_interval_precision|defined|definer|dispatch|dynamic_function|dynamic_function_code|existing|exists|extract|final|fortran|g|generated|granted|hierarchy|hold|implementation|infix|insensitive|instance|instantiable|invoker|k|key_member|key_type|length|lower|m|max|message_length|message_octet_length|message_text|method|min|mod|more|mumps|name|nullable|nullif|number|octet_length|options|overlaps|overlay|overriding|parameter_mode|parameter_name|parameter_ordinal_position|parameter_specific_catalog|parameter_specific_name|parameter_specific_schema|pascal|pli|position|repeatable|returned_length|returned_octet_length|returned_sqlstate|routine_catalog|routine_name|routine_schema|row_count|scale|schema_name|security|self|sensitive|serializable|server_name|similar|simple|source|specific_name|style|subclass_origin|sublist|substring|sum|symmetric|system|table_name|transactions_committed|transactions_rolled_back|transaction_active|transform|transforms|translate|trigger_catalog|trigger_name|trigger_schema|trim|type|uncommitted|unnamed|upper|user_defined_type_catalog|user_defined_type_name|user_defined_type_schema)$/',
253: ),
254: 4 => -1,
255: 5 => -1,
256: 6 => -1,
257: 7 =>
258: array (
259: ),
260: 8 =>
261: array (
262: ),
263: 9 =>
264: array (
265: ),
266: 10 =>
267: array (
268: ),
269: ),
270: 0 =>
271: array (
272: ),
273: 1 =>
274: array (
275: ),
276: 2 =>
277: array (
278: 0 =>
279: array (
280: ),
281: ),
282: 3 =>
283: array (
284: 0 => -1,
285: 1 => -1,
286: 2 =>
287: array (
288: ),
289: 3 =>
290: array (
291: 'reserved' => '/^((?i)absolute|action|add|admin|after|aggregate|alias|all|allocate|alter|and|any|are|array|as|asc|assertion|at|authorization|before|begin|binary|bit|blob|boolean|both|breadth|by|call|cascade|cascaded|case|cast|catalog|char|character|check|class|clob|close|collate|collation|column|commit|completion|connect|connection|constraint|constraints|constructor|continue|corresponding|create|cross|cube|current|current_date|current_path|current_role|current_time|current_timestamp|current_user|cursor|cycle|data|date|day|deallocate|dec|decimal|declare|default|deferrable|deferred|delete|depth|deref|desc|describe|descriptor|destroy|destructor|deterministic|diagnostics|dictionary|disconnect|distinct|domain|double|drop|dynamic|each|else|end|end-exec|equals|escape|every|except|exception|exec|execute|external|false|fetch|first|float|for|foreign|found|free|from|full|function|general|get|global|go|goto|grant|group|grouping|having|host|hour|identity|ignore|immediate|in|indicator|initialize|initially|inner|inout|input|insert|int|integer|intersect|interval|into|is|isolation|iterate|join|key|language|large|last|lateral|leading|left|less|level|like|limit|local|localtime|localtimestamp|locator|map|match|minute|modifies|modify|module|month|names|national|natural|nchar|nclob|new|next|no|none|not|null|numeric|object|of|off|old|on|only|open|operation|option|or|order|ordinality|out|outer|output|pad|parameter|parameters|partial|path|postfix|precision|prefix|preorder|prepare|preserve|primary|prior|privileges|procedure|public|read|reads|real|recursive|ref|references|referencing|relative|restrict|result|return|returns|revoke|right|role|rollback|rollup|routine|row|rows|savepoint|schema|scope|scroll|search|second|section|select|sequence|session|session_user|set|sets|size|smallint|some|space|specific|specifictype|sql|sqlexception|sqlstate|sqlwarning|start|state|statement|static|structure|system_user|table|temporary|terminate|than|then|time|timestamp|timezone_hour|timezone_minute|to|trailing|transaction|translation|treat|trigger|true|under|union|unique|unknown|unnest|update|usage|user|using|value|values|varchar|variable|varying|view|when|whenever|where|with|without|work|write|year|zone)$/',
292: 'keyword' => '/^((?i)abs|ada|asensitive|assignment|asymmetric|atomic|avg|between|bitvar|bit_length|c|called|cardinality|catalog_name|chain|character_length|character_set_catalog|character_set_name|character_set_schema|char_length|checked|class_origin|coalesce|cobol|collation_catalog|collation_name|collation_schema|column_name|command_function|command_function_code|committed|condition_number|connection_name|constraint_catalog|constraint_name|constraint_schema|contains|convert|count|cursor_name|datetime_interval_code|datetime_interval_precision|defined|definer|dispatch|dynamic_function|dynamic_function_code|existing|exists|extract|final|fortran|g|generated|granted|hierarchy|hold|implementation|infix|insensitive|instance|instantiable|invoker|k|key_member|key_type|length|lower|m|max|message_length|message_octet_length|message_text|method|min|mod|more|mumps|name|nullable|nullif|number|octet_length|options|overlaps|overlay|overriding|parameter_mode|parameter_name|parameter_ordinal_position|parameter_specific_catalog|parameter_specific_name|parameter_specific_schema|pascal|pli|position|repeatable|returned_length|returned_octet_length|returned_sqlstate|routine_catalog|routine_name|routine_schema|row_count|scale|schema_name|security|self|sensitive|serializable|server_name|similar|simple|source|specific_name|style|subclass_origin|sublist|substring|sum|symmetric|system|table_name|transactions_committed|transactions_rolled_back|transaction_active|transform|transforms|translate|trigger_catalog|trigger_name|trigger_schema|trim|type|uncommitted|unnamed|upper|user_defined_type_catalog|user_defined_type_name|user_defined_type_schema)$/',
293: ),
294: 4 => -1,
295: 5 => -1,
296: 6 => -1,
297: 7 =>
298: array (
299: ),
300: 8 =>
301: array (
302: ),
303: 9 =>
304: array (
305: ),
306: 10 =>
307: array (
308: ),
309: ),
310: 4 =>
311: array (
312: 0 =>
313: array (
314: ),
315: ),
316: );
317: $this->_parts = array (
318: 0 =>
319: array (
320: ),
321: 1 =>
322: array (
323: ),
324: 2 =>
325: array (
326: 0 => NULL,
327: ),
328: 3 =>
329: array (
330: 0 => NULL,
331: 1 => NULL,
332: 2 => NULL,
333: 3 => NULL,
334: 4 => NULL,
335: 5 => NULL,
336: 6 => NULL,
337: 7 => NULL,
338: 8 => NULL,
339: 9 => NULL,
340: 10 => NULL,
341: ),
342: 4 =>
343: array (
344: 0 => NULL,
345: ),
346: );
347: $this->_subst = array (
348: -1 =>
349: array (
350: 0 => false,
351: 1 => false,
352: 2 => false,
353: 3 => false,
354: 4 => false,
355: 5 => false,
356: 6 => false,
357: 7 => false,
358: 8 => false,
359: 9 => false,
360: 10 => false,
361: ),
362: 0 =>
363: array (
364: ),
365: 1 =>
366: array (
367: ),
368: 2 =>
369: array (
370: 0 => false,
371: ),
372: 3 =>
373: array (
374: 0 => false,
375: 1 => false,
376: 2 => false,
377: 3 => false,
378: 4 => false,
379: 5 => false,
380: 6 => false,
381: 7 => false,
382: 8 => false,
383: 9 => false,
384: 10 => false,
385: ),
386: 4 =>
387: array (
388: 0 => false,
389: ),
390: );
391: $this->_conditions = array (
392: );
393: $this->_kwmap = array (
394: 'reserved' => 'reserved',
395: 'keyword' => 'var',
396: );
397: $this->_defClass = 'code';
398: $this->_checkDefines();
399: }
400:
401: }