Passed
Push — master ( 442876...4ec1bc )
by Felipe
15:55 queued 10:33
created

Highlight::syntax_highlight()   C

Complexity

Conditions 16
Paths 181

Size

Total Lines 65
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 16
eloc 40
nc 181
nop 2
dl 0
loc 65
rs 5.422
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
3
 * PHPPgAdmin v6.0.0-beta.30
4
 */
5
namespace PHPPgAdmin;
6
7
/**
8
 * This software is licensed through a BSD-style License.
9
 * @see {@link http://www.opensource.org/licenses/bsd-license.php}
10
 * Copyright (c) 2003, 2004, Jacob D. Cohen
11
 * All rights reserved.
12
 *
13
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions
15
 * are met:
16
 *
17
 * Redistributions of source code must retain the above copyright notice,
18
 * this list of conditions and the following disclaimer.
19
 * Redistributions in binary form must reproduce the above copyright
20
 * notice, this list of conditions and the following disclaimer in the
21
 * documentation and/or other materials provided with the distribution.
22
 * Neither the name of Jacob D. Cohen nor the names of his contributors
23
 * may be used to endorse or promote products derived from this software
24
 * without specific prior written permission.
25
 *
26
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
 */
5 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
38
class Highlight
39
{
40
    const NORMAL_TEXT     = 1;
41
    const DQ_LITERAL      = 2;
42
    const DQ_ESCAPE       = 3;
43
    const SQ_LITERAL      = 4;
44
    const SQ_ESCAPE       = 5;
45
    const SLASH_BEGIN     = 6;
46
    const STAR_COMMENT    = 7;
47
    const STAR_END        = 8;
48
    const LINE_COMMENT    = 9;
49
    const HTML_ENTITY     = 10;
50
    const LC_ESCAPE       = 11;
51
    const BLOCK_COMMENT   = 12;
52
    const PAREN_BEGIN     = 13;
53
    const DASH_BEGIN      = 14;
54
    const BT_LITERAL      = 15;
55
    const BT_ESCAPE       = 16;
56
    const XML_TAG_BEGIN   = 17;
57
    const XML_TAG         = 18;
58
    const XML_PI          = 19;
59
    const SCH_NORMAL      = 20;
60
    const SCH_STRESC      = 21;
61
    const SCH_IDEXPR      = 22;
62
    const SCH_NUMLIT      = 23;
63
    const SCH_CHRLIT      = 24;
64
    const SCH_STRLIT      = 25;
65
    public $initial_state = ['Scheme' => self::SCH_NORMAL];
66
    public $sch           = [];
67
    public $c89           = [];
68
    public $c99           = [];
69
    public $cpp           = [];
70
    public $cs            = [];
71
    public $edges         = [];
72
    public $java          = [];
73
    public $mirc          = [];
74
    public $pascal        = [];
75
    public $perl          = [];
76
    public $php           = [];
77
    public $pli           = [];
78
    public $process       = [];
79
    public $process_end   = [];
80
    public $python        = [];
81
    public $ruby          = [];
82
    public $sql           = [];
83
    public $states        = [];
84
    public $vb            = [];
85
    public $xml           = [];
86
87
    /* Constructor */
88
89
    public function __construct()
1 ignored issue
show
Coding Style introduced by
You must use "/**" style comments for a function comment
Loading history...
90
    {
91
        $keyword_replace = function ($keywords, $text, $ncs = false) {
92
            $cm = $ncs ? 'i' : '';
93
            foreach ($keywords as $keyword) {
94
                $search[]  = "/(\\b$keyword\\b)/" . $cm;
95
                $replace[] = '<span class="keyword">\\0</span>';
96
            }
97
98
            $search[]  = "/(\\bclass\s)/";
99
            $replace[] = '<span class="keyword">\\0</span>';
100
101
            return preg_replace($search, $replace, $text);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $search seems to be defined by a foreach iteration on line 93. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
Comprehensibility Best Practice introduced by
The variable $replace seems to be defined by a foreach iteration on line 93. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
102
        };
103
104
        $preproc_replace = function ($preproc, $text) {
105
            foreach ($preproc as $proc) {
106
                $search[]  = "/(\\s*#\s*$proc\\b)/";
107
                $replace[] = '<span class="keyword">\\0</span>';
108
            }
109
110
            return preg_replace($search, $replace, $text);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $search seems to be defined by a foreach iteration on line 105. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
Comprehensibility Best Practice introduced by
The variable $replace seems to be defined by a foreach iteration on line 105. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
111
        };
112
113
        $sch_syntax_helper = function ($text) {
114
            return $text;
115
        };
116
117
        $syntax_highlight_helper = function ($text, $language) use ($keyword_replace, $preproc_replace) {
118
            $preproc        = [];
119
            $preproc['C++'] = [
120
                'if',
121
                'ifdef',
122
                'ifndef',
123
                'elif',
124
                'else',
125
                'endif',
126
                'include',
127
                'define',
128
                'undef',
129
                'line',
130
                'error',
131
                'pragma',
132
            ];
133
            $preproc['C89'] = &$preproc['C++'];
134
            $preproc['C']   = &$preproc['C89'];
135
136
            $keywords = [
137
                'C++'    => [
138
                    'asm',
139
                    'auto',
140
                    'bool',
141
                    'break',
142
                    'case',
143
                    'catch',
144
                    'char', /*class*/
145
                    'const',
146
                    'const_cast',
147
                    'continue',
148
                    'default',
149
                    'delete',
150
                    'do',
151
                    'double',
152
                    'dynamic_cast',
153
                    'else',
154
                    'enum',
155
                    'explicit',
156
                    'export',
157
                    'extern',
158
                    'false',
159
                    'float',
160
                    'for',
161
                    'friend',
162
                    'goto',
163
                    'if',
164
                    'inline',
165
                    'int',
166
                    'long',
167
                    'mutable',
168
                    'namespace',
169
                    'new',
170
                    'operator',
171
                    'private',
172
                    'protected',
173
                    'public',
174
                    'register',
175
                    'reinterpret_cast',
176
                    'return',
177
                    'short',
178
                    'signed',
179
                    'sizeof',
180
                    'static',
181
                    'static_cast',
182
                    'struct',
183
                    'switch',
184
                    'template',
185
                    'this',
186
                    'throw',
187
                    'true',
188
                    'try',
189
                    'typedef',
190
                    'typeid',
191
                    'typename',
192
                    'union',
193
                    'unsigned',
194
                    'using',
195
                    'virtual',
196
                    'void',
197
                    'volatile',
198
                    'wchar_t',
199
                    'while',
200
                ],
201
202
                'C89'    => [
203
                    'auto',
204
                    'break',
205
                    'case',
206
                    'char',
207
                    'const',
208
                    'continue',
209
                    'default',
210
                    'do',
211
                    'double',
212
                    'else',
213
                    'enum',
214
                    'extern',
215
                    'float',
216
                    'for',
217
                    'goto',
218
                    'if',
219
                    'int',
220
                    'long',
221
                    'register',
222
                    'return',
223
                    'short',
224
                    'signed',
225
                    'sizeof',
226
                    'static',
227
                    'struct',
228
                    'switch',
229
                    'typedef',
230
                    'union',
231
                    'unsigned',
232
                    'void',
233
                    'volatile',
234
                    'while',
235
                ],
236
237
                'C'      => [
238
                    'auto',
239
                    'break',
240
                    'case',
241
                    'char',
242
                    'const',
243
                    'continue',
244
                    'default',
245
                    'do',
246
                    'double',
247
                    'else',
248
                    'enum',
249
                    'extern',
250
                    'float',
251
                    'for',
252
                    'goto',
253
                    'if',
254
                    'int',
255
                    'long',
256
                    'register',
257
                    'return',
258
                    'short',
259
                    'signed',
260
                    'sizeof',
261
                    'static',
262
                    'struct',
263
                    'switch',
264
                    'typedef',
265
                    'union',
266
                    'unsigned',
267
                    'void',
268
                    'volatile',
269
                    'while',
270
                    '__restrict',
271
                    '_Bool',
272
                ],
273
274
                'PHP'    => [
275
                    'and',
276
                    'or',
277
                    'xor',
278
                    '__FILE__',
279
                    '__LINE__',
280
                    'array',
281
                    'as',
282
                    'break',
283
                    'case',
284
                    'cfunction',
285
                    /*class*/
286
                    'const',
287
                    'continue',
288
                    'declare',
289
                    'default',
290
                    'die',
291
                    'do',
292
                    'echo',
293
                    'else',
294
                    'elseif',
295
                    'empty',
296
                    'enddeclare',
297
                    'endfor',
298
                    'endforeach',
299
                    'endif',
300
                    'endswitch',
301
                    'endwhile',
302
                    'eval',
303
                    'exit',
304
                    'extends',
305
                    'for',
306
                    'foreach',
307
                    'function',
308
                    'global',
309
                    'if',
310
                    'include',
311
                    'include_once',
312
                    'isset',
313
                    'list',
314
                    'new',
315
                    'old_function',
316
                    'print',
317
                    'require',
318
                    'require_once',
319
                    'return',
320
                    'static',
321
                    'switch',
322
                    'unset',
323
                    'use',
324
                    'var',
325
                    'while',
326
                    '__FUNCTION__',
327
                    '__CLASS__',
328
                ],
329
330
                'Perl'   => [
331
                    '-A',
332
                    '-B',
333
                    '-C',
334
                    '-M',
335
                    '-O',
336
                    '-R',
337
                    '-S',
338
                    '-T',
339
                    '-W',
340
                    '-X',
341
                    '-b',
342
                    '-c',
343
                    '-d',
344
                    '-e',
345
                    '-f',
346
                    '-g',
347
                    '-k',
348
                    '-l',
349
                    '-o',
350
                    '-p',
351
                    '-r',
352
                    '-s',
353
                    '-t',
354
                    '-u',
355
                    '-w',
356
                    '-x',
357
                    '-z',
358
                    'ARGV',
359
                    'DATA',
360
                    'ENV',
361
                    'SIG',
362
                    'STDERR',
363
                    'STDIN',
364
                    'STDOUT',
365
                    'atan2',
366
                    'bind',
367
                    'binmode',
368
                    'bless',
369
                    'caller',
370
                    'chdir',
371
                    'chmod',
372
                    'chomp',
373
                    'chop',
374
                    'chown',
375
                    'chr',
376
                    'chroot',
377
                    'close',
378
                    'closedir',
379
                    'cmp',
380
                    'connect',
381
                    'continue',
382
                    'cos',
383
                    'crypt',
384
                    'dbmclose',
385
                    'dbmopen',
386
                    'defined',
387
                    'delete',
388
                    'die',
389
                    'do',
390
                    'dump',
391
                    'each',
392
                    'else',
393
                    'elsif',
394
                    'endgrent',
395
                    'endhostent',
396
                    'endnetent',
397
                    'endprotent',
398
                    'endpwent',
399
                    'endservent',
400
                    'eof',
401
                    'eq',
402
                    'eval',
403
                    'exec',
404
                    'exists',
405
                    'exit',
406
                    'exp',
407
                    'fcntl',
408
                    'fileno',
409
                    'flock',
410
                    'for',
411
                    'foreach',
412
                    'fork',
413
                    'format',
414
                    'formline',
415
                    'ge',
416
                    'getc',
417
                    'getgrent',
418
                    'getgrid',
419
                    'getgrnam',
420
                    'gethostbyaddr',
421
                    'gethostbyname',
422
                    'gethostent',
423
                    'getlogin',
424
                    'getnetbyaddr',
425
                    'getnetbyname',
426
                    'getnetent',
427
                    'getpeername',
428
                    'getpgrp',
429
                    'getppid',
430
                    'getpriority',
431
                    'getprotobyname',
432
                    'getprotobynumber',
433
                    'getprotoent',
434
                    'getpwent',
435
                    'getpwnam',
436
                    'getpwuid',
437
                    'getservbyname',
438
                    'getservbyport',
439
                    'getservent',
440
                    'getsockname',
441
                    'getsockopt',
442
                    'glob',
443
                    'gmtime',
444
                    'goto',
445
                    'grep',
446
                    /*gt*/
447
                    'hex',
448
                    'if',
449
                    'import',
450
                    'index',
451
                    'int',
452
                    'ioctl',
453
                    'join',
454
                    'keys',
455
                    'kill',
456
                    'last',
457
                    'lc',
458
                    'lcfirst',
459
                    'le',
460
                    'length',
461
                    'link',
462
                    'listen',
463
                    'local',
464
                    'localtime',
465
                    'log',
466
                    'lstat', /*lt*/
467
                    'm',
468
                    'map',
469
                    'mkdir',
470
                    'msgctl',
471
                    'msgget',
472
                    'msgrcv',
473
                    'msgsnd',
474
                    'my',
475
                    'ne',
476
                    'next',
477
                    'no',
478
                    'oct',
479
                    'open',
480
                    'opendir',
481
                    'ord',
482
                    'pack',
483
                    'package',
484
                    'pipe',
485
                    'pop',
486
                    'pos',
487
                    'print',
488
                    'printf',
489
                    'push',
490
                    'q',
491
                    'qq',
492
                    'quotemeta',
493
                    'qw',
494
                    'qx',
495
                    'rand',
496
                    'read',
497
                    'readdir',
498
                    'readlink',
499
                    'recv',
500
                    'redo',
501
                    'ref',
502
                    'refname',
503
                    'require',
504
                    'reset',
505
                    'return',
506
                    'reverse',
507
                    'rewinddir',
508
                    'rindex',
509
                    'rmdir',
510
                    's',
511
                    'scalar',
512
                    'seek',
513
                    'seekdir',
514
                    'select',
515
                    'semctl',
516
                    'semget',
517
                    'semop',
518
                    'send',
519
                    'setgrent',
520
                    'sethostent',
521
                    'setnetent',
522
                    'setpgrp',
523
                    'setpriority',
524
                    'setprotoent',
525
                    'setpwent',
526
                    'setservent',
527
                    'setsockopt',
528
                    'shift',
529
                    'shmctl',
530
                    'shmget',
531
                    'shmread',
532
                    'shmwrite',
533
                    'shutdown',
534
                    'sin',
535
                    'sleep',
536
                    'socket',
537
                    'socketpair',
538
                    'sort',
539
                    'splice',
540
                    'split',
541
                    'sprintf',
542
                    'sqrt',
543
                    'srand',
544
                    'stat',
545
                    'study',
546
                    'sub',
547
                    'substr',
548
                    'symlink',
549
                    'syscall',
550
                    'sysopen',
551
                    'sysread',
552
                    'system',
553
                    'syswrite',
554
                    'tell',
555
                    'telldir',
556
                    'tie',
557
                    'tied',
558
                    'time',
559
                    'times',
560
                    'tr',
561
                    'truncate',
562
                    'uc',
563
                    'ucfirst',
564
                    'umask',
565
                    'undef',
566
                    'unless',
567
                    'unlink',
568
                    'unpack',
569
                    'unshift',
570
                    'untie',
571
                    'until',
572
                    'use',
573
                    'utime',
574
                    'values',
575
                    'vec',
576
                    'wait',
577
                    'waitpid',
578
                    'wantarray',
579
                    'warn',
580
                    'while',
581
                    'write',
582
                    'y',
583
                    'or',
584
                    'and',
585
                    'not',
586
                ],
587
588
                'Java'   => [
589
                    'abstract',
590
                    'boolean',
591
                    'break',
592
                    'byte',
593
                    'case',
594
                    'catch',
595
                    'char', /*class*/
596
                    'const',
597
                    'continue',
598
                    'default',
599
                    'do',
600
                    'double',
601
                    'else',
602
                    'extends',
603
                    'final',
604
                    'finally',
605
                    'float',
606
                    'for',
607
                    'goto',
608
                    'if',
609
                    'implements',
610
                    'import',
611
                    'instanceof',
612
                    'int',
613
                    'interface',
614
                    'long',
615
                    'native',
616
                    'new',
617
                    'package',
618
                    'private',
619
                    'protected',
620
                    'public',
621
                    'return',
622
                    'short',
623
                    'static',
624
                    'strictfp',
625
                    'super',
626
                    'switch',
627
                    'synchronized',
628
                    'this',
629
                    'throw',
630
                    'throws',
631
                    'transient',
632
                    'try',
633
                    'void',
634
                    'volatile',
635
                    'while',
636
                ],
637
638
                'VB'     => [
639
                    'AddressOf',
640
                    'Alias',
641
                    'And',
642
                    'Any',
643
                    'As',
644
                    'Binary',
645
                    'Boolean',
646
                    'ByRef',
647
                    'Byte',
648
                    'ByVal',
649
                    'Call',
650
                    'Case',
651
                    'CBool',
652
                    'CByte',
653
                    'CCur',
654
                    'CDate',
655
                    'CDbl',
656
                    'CInt',
657
                    'CLng',
658
                    'Close',
659
                    'Const',
660
                    'CSng',
661
                    'CStr',
662
                    'Currency',
663
                    'CVar',
664
                    'CVErr',
665
                    'Date',
666
                    'Debug',
667
                    'Declare',
668
                    'DefBool',
669
                    'DefByte',
670
                    'DefCur',
671
                    'DefDate',
672
                    'DefDbl',
673
                    'DefInt',
674
                    'DefLng',
675
                    'DefObj',
676
                    'DefSng',
677
                    'DefStr',
678
                    'DefVar',
679
                    'Dim',
680
                    'Do',
681
                    'Double',
682
                    'Each',
683
                    'Else',
684
                    'End',
685
                    'Enum',
686
                    'Eqv',
687
                    'Erase',
688
                    'Error',
689
                    'Event',
690
                    'Exit',
691
                    'For',
692
                    'Friend',
693
                    'Function',
694
                    'Get',
695
                    'Get',
696
                    'Global',
697
                    'GoSub',
698
                    'GoTo',
699
                    'If',
700
                    'Imp',
701
                    'Implements',
702
                    'In',
703
                    'Input',
704
                    'Integer',
705
                    'Is',
706
                    'LBound',
707
                    'Len',
708
                    'Let',
709
                    'Lib',
710
                    'Like',
711
                    'Line',
712
                    'Lock',
713
                    'Long',
714
                    'Loop',
715
                    'LSet',
716
                    'Mod',
717
                    'Name',
718
                    'Next',
719
                    'Not',
720
                    'Nothing',
721
                    'Null',
722
                    'Object',
723
                    'On',
724
                    'Open',
725
                    'Option Base 1',
726
                    'Option Compare Binary',
727
                    'Option Compare Database',
728
                    'Option Compare Text',
729
                    'Option Explicit',
730
                    'Option Private Module',
731
                    'Optional',
732
                    'Or',
733
                    'Output',
734
                    'ParamArray',
735
                    'Preserve',
736
                    'Print',
737
                    'Private',
738
                    'Property',
739
                    'Public',
740
                    'Put',
741
                    'RaiseEvent',
742
                    'Random',
743
                    'Read',
744
                    'ReDim',
745
                    'Resume',
746
                    'Return',
747
                    'RSet',
748
                    'Seek',
749
                    'Select',
750
                    'Set',
751
                    'Single',
752
                    'Spc',
753
                    'Static',
754
                    'Step',
755
                    'Stop',
756
                    'String',
757
                    'Sub',
758
                    'Tab',
759
                    'Then',
760
                    'To',
761
                    'Type',
762
                    'UBound',
763
                    'Unlock',
764
                    'Variant',
765
                    'Wend',
766
                    'While',
767
                    'With',
768
                    'WithEvents',
769
                    'Write',
770
                    'Xor',
771
                ],
772
773
                'C#'     => [
774
                    'abstract',
775
                    'as',
776
                    'base',
777
                    'bool',
778
                    'break',
779
                    'byte',
780
                    'case',
781
                    'catch',
782
                    'char',
783
                    'checked',
784
                    /*class*/
785
                    'const',
786
                    'continue',
787
                    'decimal',
788
                    'default',
789
                    'delegate',
790
                    'do',
791
                    'double',
792
                    'else',
793
                    'enum',
794
                    'event',
795
                    'explicit',
796
                    'extern',
797
                    'false',
798
                    'finally',
799
                    'fixed',
800
                    'float',
801
                    'for',
802
                    'foreach',
803
                    'goto',
804
                    'if',
805
                    'implicit',
806
                    'in',
807
                    'int',
808
                    'interface',
809
                    'internal',
810
                    'is',
811
                    'lock',
812
                    'long',
813
                    'namespace',
814
                    'new',
815
                    'null',
816
                    'object',
817
                    'operator',
818
                    'out',
819
                    'override',
820
                    'params',
821
                    'private',
822
                    'protected',
823
                    'public',
824
                    'readonly',
825
                    'ref',
826
                    'return',
827
                    'sbyte',
828
                    'sealed',
829
                    'short',
830
                    'sizeof',
831
                    'stackalloc',
832
                    'static',
833
                    'string',
834
                    'struct',
835
                    'switch',
836
                    'this',
837
                    'throw',
838
                    'true',
839
                    'try',
840
                    'typeof',
841
                    'uint',
842
                    'ulong',
843
                    'unchecked',
844
                    'unsafe',
845
                    'ushort',
846
                    'using',
847
                    'virtual',
848
                    'volatile',
849
                    'void',
850
                    'while',
851
                ],
852
853
                'Ruby'   => [
854
                    'alias',
855
                    'and',
856
                    'begin',
857
                    'break',
858
                    'case',
859
                    /*class*/
860
                    'def',
861
                    'defined',
862
                    'do',
863
                    'else',
864
                    'elsif',
865
                    'end',
866
                    'ensure',
867
                    'false',
868
                    'for',
869
                    'if',
870
                    'in',
871
                    'module',
872
                    'next',
873
                    'module',
874
                    'next',
875
                    'nil',
876
                    'not',
877
                    'or',
878
                    'redo',
879
                    'rescue',
880
                    'retry',
881
                    'return',
882
                    'self',
883
                    'super',
884
                    'then',
885
                    'true',
886
                    'undef',
887
                    'unless',
888
                    'until',
889
                    'when',
890
                    'while',
891
                    'yield',
892
                ],
893
894
                'Python' => [
895
                    'and',
896
                    'assert',
897
                    'break', /*"class",*/
898
                    'continue',
899
                    'def',
900
                    'del',
901
                    'elif',
902
                    'else',
903
                    'except',
904
                    'exec',
905
                    'finally',
906
                    'for',
907
                    'from',
908
                    'global',
909
                    'if',
910
                    'import',
911
                    'in',
912
                    'is',
913
                    'lambda',
914
                    'not',
915
                    'or',
916
                    'pass',
917
                    'print',
918
                    'raise',
919
                    'return',
920
                    'try',
921
                    'while',
922
                    'yield',
923
                ],
924
925
                'Pascal' => [
926
                    'Absolute',
927
                    'Abstract',
928
                    'All',
929
                    'And',
930
                    'And_then',
931
                    'Array',
932
                    'Asm',
933
                    'Begin',
934
                    'Bindable',
935
                    'Case',
936
                    /*"Class",*/
937
                    'Const',
938
                    'Constructor',
939
                    'Destructor',
940
                    'Div',
941
                    'Do',
942
                    'Downto',
943
                    'Else',
944
                    'End',
945
                    'Export',
946
                    'File',
947
                    'For',
948
                    'Function',
949
                    'Goto',
950
                    'If',
951
                    'Import',
952
                    'Implementation',
953
                    'Inherited',
954
                    'In',
955
                    'Inline',
956
                    'Interface',
957
                    'Is',
958
                    'Label',
959
                    'Mod',
960
                    'Module',
961
                    'Nil',
962
                    'Not',
963
                    'Object',
964
                    'Of',
965
                    'Only',
966
                    'Operator',
967
                    'Or',
968
                    'Or_else',
969
                    'Otherwise',
970
                    'Packed',
971
                    'Pow',
972
                    'Procedure',
973
                    'Program',
974
                    'Property',
975
                    'Protected',
976
                    'Qualified',
977
                    'Record',
978
                    'Repeat',
979
                    'Restricted',
980
                    'Set',
981
                    'Shl',
982
                    'Shr',
983
                    'Then',
984
                    'To',
985
                    'Type',
986
                    'Unit',
987
                    'Until',
988
                    'Uses',
989
                    'Value',
990
                    'Var',
991
                    'View',
992
                    'Virtual',
993
                    'While',
994
                    'With',
995
                    'Xor',
996
                ],
997
998
                'mIRC'   => [
999
                ],
1000
1001
                'PL/I'   => [
1002
                    'A',
1003
                    'ABS',
1004
                    'ACOS',
1005
                    '%ACTIVATE',
1006
                    'ACTUALCOUNT',
1007
                    'ADD',
1008
                    'ADDR',
1009
                    'ADDREL',
1010
                    'ALIGNED',
1011
                    'ALLOCATE',
1012
                    'ALLOC',
1013
                    'ALLOCATION',
1014
                    'ALLOCN',
1015
                    'ANY',
1016
                    'ANYCONDITION',
1017
                    'APPEND',
1018
                    'AREA',
1019
                    'ASIN',
1020
                    'ATAN',
1021
                    'ATAND',
1022
                    'ATANH',
1023
                    'AUTOMATIC',
1024
                    'AUTO',
1025
                    'B',
1026
                    'B1',
1027
                    'B2',
1028
                    'B3',
1029
                    'B4',
1030
                    'BACKUP_DATE',
1031
                    'BASED',
1032
                    'BATCH',
1033
                    'BEGIN',
1034
                    'BINARY',
1035
                    'BIN',
1036
                    'BIT',
1037
                    'BLOCK_BOUNDARY_FORMAT',
1038
                    'BLOCK_IO',
1039
                    'BLOCK_SIZE',
1040
                    'BOOL',
1041
                    'BUCKET_SIZE',
1042
                    'BUILTIN',
1043
                    'BY',
1044
                    'BYTE',
1045
                    'BYTESIZE',
1046
                    'CALL',
1047
                    'CANCEL_CONTROL_O',
1048
                    'CARRIAGE_RETURN_FORMAT',
1049
                    'CEIL',
1050
                    'CHAR',
1051
                    'CHARACTER',
1052
                    'CLOSE',
1053
                    'COLLATE',
1054
                    'COLUMN',
1055
                    'CONDITION',
1056
                    'CONTIGUOUS',
1057
                    'CONTIGUOUS_BEST_TRY',
1058
                    'CONTROLLED',
1059
                    'CONVERSION',
1060
                    'COPY',
1061
                    'COS',
1062
                    'COSD',
1063
                    'COSH',
1064
                    'CREATION_DATE',
1065
                    'CURRENT_POSITION',
1066
                    'DATE',
1067
                    'DATETIME',
1068
                    '%DEACTIVATE',
1069
                    'DECIMAL',
1070
                    'DEC',
1071
                    '%DECLARE',
1072
                    '%DCL',
1073
                    'DECLARE',
1074
                    'DCL',
1075
                    'DECODE',
1076
                    'DEFAULT_FILE_NAME',
1077
                    'DEFERRED_WRITE',
1078
                    'DEFINED',
1079
                    'DEF',
1080
                    'DELETE',
1081
                    'DESCRIPTOR',
1082
                    '%DICTIONARY',
1083
                    'DIMENSION',
1084
                    'DIM',
1085
                    'DIRECT',
1086
                    'DISPLAY',
1087
                    'DIVIDE',
1088
                    '%DO',
1089
                    'DO',
1090
                    'E',
1091
                    'EDIT',
1092
                    '%ELSE',
1093
                    'ELSE',
1094
                    'EMPTY',
1095
                    'ENCODE',
1096
                    '%END',
1097
                    'END',
1098
                    'ENDFILE',
1099
                    'ENDPAGE',
1100
                    'ENTRY',
1101
                    'ENVIRONMENT',
1102
                    'ENV',
1103
                    '%ERROR',
1104
                    'ERROR',
1105
                    'EVERY',
1106
                    'EXP',
1107
                    'EXPIRATION_DATE',
1108
                    'EXTEND',
1109
                    'EXTENSION_SIZE',
1110
                    'EXTERNAL',
1111
                    'EXT',
1112
                    'F',
1113
                    'FAST_DELETE',
1114
                    '%FATAL',
1115
                    'FILE',
1116
                    'FILE_ID',
1117
                    'FILE_ID_TO',
1118
                    'FILE_SIZE',
1119
                    'FINISH',
1120
                    'FIXED',
1121
                    'FIXEDOVERFLOW',
1122
                    'FOFL',
1123
                    'FIXED_CONTROL_FROM',
1124
                    'FIXED_CONTROL_SIZE',
1125
                    'FIXED_CONTROL_SIZE_TO',
1126
                    'FIXED_CONTROL_TO',
1127
                    'FIXED_LENGTH_RECORDS',
1128
                    'FLOAT',
1129
                    'FLOOR',
1130
                    'FLUSH',
1131
                    'FORMAT',
1132
                    'FREE',
1133
                    'FROM',
1134
                    'GET',
1135
                    'GLOBALDEF',
1136
                    'GLOBALREF',
1137
                    '%GOTO',
1138
                    'GOTO',
1139
                    'GO',
1140
                    'TO',
1141
                    'GROUP_PROTETION',
1142
                    'HBOUND',
1143
                    'HIGH',
1144
                    'INDENT',
1145
                    '%IF',
1146
                    'IF',
1147
                    'IGNORE_LINE_MARKS',
1148
                    'IN',
1149
                    '%INCLUDE',
1150
                    'INDEX',
1151
                    'INDEXED',
1152
                    'INDEX_NUMBER',
1153
                    '%INFORM',
1154
                    'INFORM',
1155
                    'INITIAL',
1156
                    'INIT',
1157
                    'INITIAL_FILL',
1158
                    'INPUT',
1159
                    'INT',
1160
                    'INTERNAL',
1161
                    'INTO',
1162
                    'KEY',
1163
                    'KEYED',
1164
                    'KEYFROM',
1165
                    'KEYTO',
1166
                    'LABEL',
1167
                    'LBOUND',
1168
                    'LEAVE',
1169
                    'LENGTH',
1170
                    'LIKE',
1171
                    'LINE',
1172
                    'LINENO',
1173
                    'LINESIZE',
1174
                    '%LIST',
1175
                    'LIST',
1176
                    'LOCK_ON_READ',
1177
                    'LOCK_ON_WRITE',
1178
                    'LOG',
1179
                    'LOG10',
1180
                    'LOG2',
1181
                    'LOW',
1182
                    'LTRIM',
1183
                    'MAIN',
1184
                    'MANUAL_UNLOCKING',
1185
                    'MATCH_GREATER',
1186
                    'MATCH_GREATER_EQUAL',
1187
                    'MATCH_NEXT',
1188
                    'MATCH_NEXT_EQUAL',
1189
                    'MAX',
1190
                    'MAXIMUM_RECORD_NUMBER',
1191
                    'MAXIMUM_RECORD_SIZE',
1192
                    'MAXLENGTH',
1193
                    'MEMBER',
1194
                    'MIN',
1195
                    'MOD',
1196
                    'MULTIBLOCK_COUNT',
1197
                    'MULTIBUFFER_COUNT',
1198
                    'MULTIPLY',
1199
                    'NEXT_VOLUME',
1200
                    '%NOLIST',
1201
                    'NOLOCK',
1202
                    'NONEXISTENT_RECORD',
1203
                    'NONRECURSIVE',
1204
                    'NONVARYING',
1205
                    'NONVAR',
1206
                    'NORESCAN',
1207
                    'NO_ECHO',
1208
                    'NO_FILTER',
1209
                    'NO_SHARE',
1210
                    'NULL',
1211
                    'OFFSET',
1212
                    'ON',
1213
                    'ONARGSLIST',
1214
                    'ONCHAR',
1215
                    'ONCODE',
1216
                    'ONFILE',
1217
                    'ONKEY',
1218
                    'ONSOURCE',
1219
                    'OPEN',
1220
                    'OPTIONAL',
1221
                    'OPTIONS',
1222
                    'OTHERWISE',
1223
                    'OTHER',
1224
                    'OUTPUT',
1225
                    'OVERFLOW',
1226
                    'OFL',
1227
                    'OWNER_GROUP',
1228
                    'OWNER_ID',
1229
                    'OWNER_MEMBER',
1230
                    'OWNER_PROTECTION',
1231
                    'P',
1232
                    '%PAGE',
1233
                    'PAGE',
1234
                    'PAGENO',
1235
                    'PAGESIZE',
1236
                    'PARAMETER',
1237
                    'PARM',
1238
                    'PICTURE',
1239
                    'PIC',
1240
                    'POINTER',
1241
                    'PTR',
1242
                    'POSINT',
1243
                    'POSITION',
1244
                    'POS',
1245
                    'PRECISION',
1246
                    'PREC',
1247
                    'PRESENT',
1248
                    'PRINT',
1249
                    'PRINTER_FORMAT',
1250
                    '%PROCEDURE',
1251
                    '%PROC',
1252
                    'PROCEDURE',
1253
                    'PROC',
1254
                    'PROD',
1255
                    'PROMPT',
1256
                    'PURGE_TYPE_AHEAD',
1257
                    'PUT',
1258
                    'R',
1259
                    'RANK',
1260
                    'READ',
1261
                    'READONLY',
1262
                    'READ_AHEAD',
1263
                    'READ_CHECK',
1264
                    'READ_REGARDLESS',
1265
                    'RECORD',
1266
                    'RECORD_ID',
1267
                    'RECORD_ID_ACCESS',
1268
                    'RECORD_ID_TO',
1269
                    'RECURSIVE',
1270
                    'REFER',
1271
                    'REFERENCE',
1272
                    'RELEASE',
1273
                    'REPEAT',
1274
                    '%REPLACE',
1275
                    'RESCAN',
1276
                    'RESIGNAL',
1277
                    'RETRIEVAL_POINTERS',
1278
                    '%RETURN',
1279
                    'RETURN',
1280
                    'RETURNS',
1281
                    'REVERSE',
1282
                    'REVERT',
1283
                    'REVISION_DATE',
1284
                    'REWIND',
1285
                    'REWIND_ON_CLOSE',
1286
                    'REWIND_ON_OPEN',
1287
                    'REWRITE',
1288
                    'ROUND',
1289
                    'RTRIM',
1290
                    '%SBTTL',
1291
                    'SCALARVARYING',
1292
                    'SEARCH',
1293
                    'SELECT',
1294
                    'SEQUENTIAL',
1295
                    'SEQL',
1296
                    'SET',
1297
                    'SHARED_READ',
1298
                    'SHARED_WRITE',
1299
                    'SIGN',
1300
                    'SIGNAL',
1301
                    'SIN',
1302
                    'SIND',
1303
                    'SINH',
1304
                    'SIZE',
1305
                    'SKIP',
1306
                    'SNAP',
1307
                    'SOME',
1308
                    'SPACEBLOCK',
1309
                    'SPOOL',
1310
                    'SQRT',
1311
                    'STATEMENT',
1312
                    'STATIC',
1313
                    'STOP',
1314
                    'STORAGE',
1315
                    'STREAM',
1316
                    'STRING',
1317
                    'STRINGRANGE',
1318
                    'STRG',
1319
                    'STRUCTURE',
1320
                    'SUBSCRIPTRANGE',
1321
                    'SUBRG',
1322
                    'SUBSTR',
1323
                    'SUBTRACT',
1324
                    'SUM',
1325
                    'SUPERCEDE',
1326
                    'SYSIN',
1327
                    'SYSPRINT',
1328
                    'SYSTEM',
1329
                    'SYSTEM_PROTECTION',
1330
                    'TAB',
1331
                    'TAN',
1332
                    'TAND',
1333
                    'TANH',
1334
                    'TEMPORARY',
1335
                    '%THEN',
1336
                    'THEN',
1337
                    'TIME',
1338
                    'TIMEOUT_PERIOD',
1339
                    '%TITLE',
1340
                    'TITLE',
1341
                    'TO',
1342
                    'TRANSLATE',
1343
                    'TRIM',
1344
                    'TRUNC',
1345
                    'TRUNCATE',
1346
                    'UNALIGNED',
1347
                    'UNAL',
1348
                    'UNDEFINED',
1349
                    'UNDF',
1350
                    'UNDERFLOW',
1351
                    'UFL',
1352
                    'UNION',
1353
                    'UNSPEC',
1354
                    'UNTIL',
1355
                    'UPDATE',
1356
                    'USER_OPEN',
1357
                    'VALID',
1358
                    'VALUE',
1359
                    'VAL',
1360
                    'VARIABLE',
1361
                    'VARIANT',
1362
                    'VARYING',
1363
                    'VAR',
1364
                    'VAXCONDITION',
1365
                    'VERIFY',
1366
                    'WAIT_FOR_RECORD',
1367
                    '%WARN',
1368
                    'WARN',
1369
                    'WHEN',
1370
                    'WHILE',
1371
                    'WORLD_PROTECTION',
1372
                    'WRITE',
1373
                    'WRITE_BEHIND',
1374
                    'WRITE_CHECK',
1375
                    'X',
1376
                    'ZERODIVIDE',
1377
                ],
1378
1379
                'SQL'    => [
1380
                    'abort',
1381
                    'abs',
1382
                    'absolute',
1383
                    'access',
1384
                    'action',
1385
                    'ada',
1386
                    'add',
1387
                    'admin',
1388
                    'after',
1389
                    'aggregate',
1390
                    'alias',
1391
                    'all',
1392
                    'allocate',
1393
                    'alter',
1394
                    'analyse',
1395
                    'analyze',
1396
                    'and',
1397
                    'any',
1398
                    'are',
1399
                    'array',
1400
                    'as',
1401
                    'asc',
1402
                    'asensitive',
1403
                    'assertion',
1404
                    'assignment',
1405
                    'asymmetric',
1406
                    'at',
1407
                    'atomic',
1408
                    'authorization',
1409
                    'avg',
1410
                    'backward',
1411
                    'before',
1412
                    'begin',
1413
                    'between',
1414
                    'bigint',
1415
                    'binary',
1416
                    'bit',
1417
                    'bitvar',
1418
                    'bit_length',
1419
                    'blob',
1420
                    'boolean',
1421
                    'both',
1422
                    'breadth',
1423
                    'by',
1424
                    'c',
1425
                    'cache',
1426
                    'call',
1427
                    'called',
1428
                    'cardinality',
1429
                    'cascade',
1430
                    'cascaded',
1431
                    'case',
1432
                    'cast',
1433
                    'catalog',
1434
                    'catalog_name',
1435
                    'chain',
1436
                    'char',
1437
                    'character',
1438
                    'characteristics',
1439
                    'character_length',
1440
                    'character_set_catalog',
1441
                    'character_set_name',
1442
                    'character_set_schema',
1443
                    'char_length',
1444
                    'check',
1445
                    'checked',
1446
                    'checkpoint', /* "class", */
1447
                    'class_origin',
1448
                    'clob',
1449
                    'close',
1450
                    'cluster',
1451
                    'coalesce',
1452
                    'cobol',
1453
                    'collate',
1454
                    'collation',
1455
                    'collation_catalog',
1456
                    'collation_name',
1457
                    'collation_schema',
1458
                    'column',
1459
                    'column_name',
1460
                    'command_function',
1461
                    'command_function_code',
1462
                    'comment',
1463
                    'commit',
1464
                    'committed',
1465
                    'completion',
1466
                    'condition_number',
1467
                    'connect',
1468
                    'connection',
1469
                    'connection_name',
1470
                    'constraint',
1471
                    'constraints',
1472
                    'constraint_catalog',
1473
                    'constraint_name',
1474
                    'constraint_schema',
1475
                    'constructor',
1476
                    'contains',
1477
                    'continue',
1478
                    'conversion',
1479
                    'convert',
1480
                    'copy',
1481
                    'corresponding',
1482
                    'count',
1483
                    'create',
1484
                    'createdb',
1485
                    'createuser',
1486
                    'cross',
1487
                    'cube',
1488
                    'current',
1489
                    'current_date',
1490
                    'current_path',
1491
                    'current_role',
1492
                    'current_time',
1493
                    'current_timestamp',
1494
                    'current_user',
1495
                    'cursor',
1496
                    'cursor_name',
1497
                    'cycle',
1498
                    'data',
1499
                    'database',
1500
                    'date',
1501
                    'datetime_interval_code',
1502
                    'datetime_interval_precision',
1503
                    'day',
1504
                    'deallocate',
1505
                    'dec',
1506
                    'decimal',
1507
                    'declare',
1508
                    'default',
1509
                    'defaults',
1510
                    'deferrable',
1511
                    'deferred',
1512
                    'defined',
1513
                    'definer',
1514
                    'delete',
1515
                    'delimiter',
1516
                    'delimiters',
1517
                    'depth',
1518
                    'deref',
1519
                    'desc',
1520
                    'describe',
1521
                    'descriptor',
1522
                    'destroy',
1523
                    'destructor',
1524
                    'deterministic',
1525
                    'diagnostics',
1526
                    'dictionary',
1527
                    'disconnect',
1528
                    'dispatch',
1529
                    'distinct',
1530
                    'do',
1531
                    'domain',
1532
                    'double',
1533
                    'drop',
1534
                    'dynamic',
1535
                    'dynamic_function',
1536
                    'dynamic_function_code',
1537
                    'each',
1538
                    'else',
1539
                    'encoding',
1540
                    'encrypted',
1541
                    'end',
1542
                    'end-exec',
1543
                    'equals',
1544
                    'escape',
1545
                    'every',
1546
                    'except',
1547
                    'exception',
1548
                    'excluding',
1549
                    'exclusive',
1550
                    'exec',
1551
                    'execute',
1552
                    'existing',
1553
                    'exists',
1554
                    'explain',
1555
                    'external',
1556
                    'extract',
1557
                    'false',
1558
                    'fetch',
1559
                    'final',
1560
                    'first',
1561
                    'float',
1562
                    'for',
1563
                    'force',
1564
                    'foreign',
1565
                    'fortran',
1566
                    'forward',
1567
                    'found',
1568
                    'free',
1569
                    'freeze',
1570
                    'from',
1571
                    'full',
1572
                    'function',
1573
                    'g',
1574
                    'general',
1575
                    'generated',
1576
                    'get',
1577
                    'global',
1578
                    'go',
1579
                    'goto',
1580
                    'grant',
1581
                    'granted',
1582
                    'group',
1583
                    'grouping',
1584
                    'handler',
1585
                    'having',
1586
                    'hierarchy',
1587
                    'hold',
1588
                    'host',
1589
                    'hour',
1590
                    'identity',
1591
                    'ignore',
1592
                    'ilike',
1593
                    'immediate',
1594
                    'immutable',
1595
                    'implementation',
1596
                    'implicit',
1597
                    'in',
1598
                    'including',
1599
                    'increment',
1600
                    'index',
1601
                    'indicator',
1602
                    'infix',
1603
                    'inherits',
1604
                    'initialize',
1605
                    'initially',
1606
                    'inner',
1607
                    'inout',
1608
                    'input',
1609
                    'insensitive',
1610
                    'insert',
1611
                    'instance',
1612
                    'instantiable',
1613
                    'instead',
1614
                    'int',
1615
                    'integer',
1616
                    'intersect',
1617
                    'interval',
1618
                    'into',
1619
                    'invoker',
1620
                    'is',
1621
                    'isnull',
1622
                    'isolation',
1623
                    'iterate',
1624
                    'join',
1625
                    'k',
1626
                    'key',
1627
                    'key_member',
1628
                    'key_type',
1629
                    'lancompiler',
1630
                    'language',
1631
                    'large',
1632
                    'last',
1633
                    'lateral',
1634
                    'leading',
1635
                    'left',
1636
                    'length',
1637
                    'less',
1638
                    'level',
1639
                    'like',
1640
                    'limit',
1641
                    'listen',
1642
                    'load',
1643
                    'local',
1644
                    'localtime',
1645
                    'localtimestamp',
1646
                    'location',
1647
                    'locator',
1648
                    'lock',
1649
                    'lower',
1650
                    'm',
1651
                    'map',
1652
                    'match',
1653
                    'max',
1654
                    'maxvalue',
1655
                    'message_length',
1656
                    'message_octet_length',
1657
                    'message_text',
1658
                    'method',
1659
                    'min',
1660
                    'minute',
1661
                    'minvalue',
1662
                    'mod',
1663
                    'mode',
1664
                    'modifies',
1665
                    'modify',
1666
                    'module',
1667
                    'month',
1668
                    'more',
1669
                    'move',
1670
                    'mumps',
1671
                    'name',
1672
                    'names',
1673
                    'national',
1674
                    'natural',
1675
                    'nchar',
1676
                    'nclob',
1677
                    'new',
1678
                    'next',
1679
                    'no',
1680
                    'nocreatedb',
1681
                    'nocreateuser',
1682
                    'none',
1683
                    'not',
1684
                    'nothing',
1685
                    'notify',
1686
                    'notnull',
1687
                    'null',
1688
                    'nullable',
1689
                    'nullif',
1690
                    'number',
1691
                    'numeric',
1692
                    'object',
1693
                    'octet_length',
1694
                    'of',
1695
                    'off',
1696
                    'offset',
1697
                    'oids',
1698
                    'old',
1699
                    'on',
1700
                    'only',
1701
                    'open',
1702
                    'operation',
1703
                    'operator',
1704
                    'option',
1705
                    'options',
1706
                    'or',
1707
                    'order',
1708
                    'ordinality',
1709
                    'out',
1710
                    'outer',
1711
                    'output',
1712
                    'overlaps',
1713
                    'overlay',
1714
                    'overriding',
1715
                    'owner',
1716
                    'pad',
1717
                    'parameter',
1718
                    'parameters',
1719
                    'parameter_mode',
1720
                    'parameter_name',
1721
                    'parameter_ordinal_position',
1722
                    'parameter_specific_catalog',
1723
                    'parameter_specific_name',
1724
                    'parameter_specific_schema',
1725
                    'partial',
1726
                    'pascal',
1727
                    'password',
1728
                    'path',
1729
                    'pendant',
1730
                    'placing',
1731
                    'pli',
1732
                    'position',
1733
                    'postfix',
1734
                    'precision',
1735
                    'prefix',
1736
                    'preorder',
1737
                    'prepare',
1738
                    'preserve',
1739
                    'primary',
1740
                    'prior',
1741
                    'privileges',
1742
                    'procedural',
1743
                    'procedure',
1744
                    'public',
1745
                    'read',
1746
                    'reads',
1747
                    'real',
1748
                    'recheck',
1749
                    'recursive',
1750
                    'ref',
1751
                    'references',
1752
                    'referencing',
1753
                    'reindex',
1754
                    'relative',
1755
                    'rename',
1756
                    'repeatable',
1757
                    'replace',
1758
                    'reset',
1759
                    'restart',
1760
                    'restrict',
1761
                    'result',
1762
                    'return',
1763
                    'returned_length',
1764
                    'returned_octet_length',
1765
                    'returned_sqlstate',
1766
                    'returns',
1767
                    'revoke',
1768
                    'right',
1769
                    'role',
1770
                    'rollback',
1771
                    'rollup',
1772
                    'routine',
1773
                    'routine_catalog',
1774
                    'routine_name',
1775
                    'routine_schema',
1776
                    'row',
1777
                    'rows',
1778
                    'row_count',
1779
                    'rule',
1780
                    'savepoint',
1781
                    'scale',
1782
                    'schema',
1783
                    'schema_name',
1784
                    'scope',
1785
                    'scroll',
1786
                    'search',
1787
                    'second',
1788
                    'section',
1789
                    'security',
1790
                    'select',
1791
                    'self',
1792
                    'sensitive',
1793
                    'sequence',
1794
                    'serializable',
1795
                    'server_name',
1796
                    'session',
1797
                    'session_user',
1798
                    'set',
1799
                    'setof',
1800
                    'sets',
1801
                    'share',
1802
                    'show',
1803
                    'similar',
1804
                    'simple',
1805
                    'size',
1806
                    'smallint',
1807
                    'some',
1808
                    'source',
1809
                    'space',
1810
                    'specific',
1811
                    'specifictype',
1812
                    'specific_name',
1813
                    'sql',
1814
                    'sqlcode',
1815
                    'sqlerror',
1816
                    'sqlexception',
1817
                    'sqlstate',
1818
                    'sqlwarning',
1819
                    'stable',
1820
                    'start',
1821
                    'state',
1822
                    'statement',
1823
                    'static',
1824
                    'statistics',
1825
                    'stdin',
1826
                    'stdout',
1827
                    'storage',
1828
                    'strict',
1829
                    'structure',
1830
                    'style',
1831
                    'subclass_origin',
1832
                    'sublist',
1833
                    'substring',
1834
                    'sum',
1835
                    'symmetric',
1836
                    'sysid',
1837
                    'system',
1838
                    'system_user',
1839
                    'table',
1840
                    'table_name',
1841
                    'temp',
1842
                    'template',
1843
                    'temporary',
1844
                    'terminate',
1845
                    'text',
1846
                    'than',
1847
                    'then',
1848
                    'time',
1849
                    'timestamp',
1850
                    'timezone_hour',
1851
                    'timezone_minute',
1852
                    'to',
1853
                    'toast',
1854
                    'trailing',
1855
                    'transaction',
1856
                    'transactions_committed',
1857
                    'transactions_rolled_back',
1858
                    'transaction_active',
1859
                    'transform',
1860
                    'transforms',
1861
                    'translate',
1862
                    'translation',
1863
                    'treat',
1864
                    'trigger',
1865
                    'trigger_catalog',
1866
                    'trigger_name',
1867
                    'trigger_schema',
1868
                    'trim',
1869
                    'true',
1870
                    'truncate',
1871
                    'trusted',
1872
                    'type',
1873
                    'uncommitted',
1874
                    'under',
1875
                    'unencrypted',
1876
                    'union',
1877
                    'unique',
1878
                    'unknown',
1879
                    'unlisten',
1880
                    'unnamed',
1881
                    'unnest',
1882
                    'until',
1883
                    'update',
1884
                    'upper',
1885
                    'usage',
1886
                    'user',
1887
                    'user_defined_type_catalog',
1888
                    'user_defined_type_name',
1889
                    'user_defined_type_schema',
1890
                    'using',
1891
                    'vacuum',
1892
                    'valid',
1893
                    'validator',
1894
                    'value',
1895
                    'values',
1896
                    'varchar',
1897
                    'variable',
1898
                    'varying',
1899
                    'verbose',
1900
                    'version',
1901
                    'view',
1902
                    'volatile',
1903
                    'when',
1904
                    'whenever',
1905
                    'where',
1906
                    'with',
1907
                    'without',
1908
                    'work',
1909
                    'write',
1910
                    'year',
1911
                    'zone',
1912
                ],
1913
1914
            ];
1915
1916
            $case_insensitive = [
1917
                'VB'     => true,
1918
                'Pascal' => true,
1919
                'PL/I'   => true,
1920
                'SQL'    => true,
1921
            ];
1922
            $ncs = false;
1923
            if (array_key_exists($language, $case_insensitive)) {
1924
                $ncs = true;
1925
            }
1926
1927
            $text = array_key_exists($language, $preproc) ?
1928
            $preproc_replace($preproc[$language], $text) :
1929
            $text;
1930
            $text = array_key_exists($language, $keywords) ?
1931
            $keyword_replace($keywords[$language], $text, $ncs) :
1932
            $text;
1933
1934
            return $text;
1935
        };
1936
1937
        $rtrim1 = function ($span, $lang, $ch) use ($syntax_highlight_helper) {
1 ignored issue
show
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1937
        $rtrim1 = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) use ($syntax_highlight_helper) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1938
            return $syntax_highlight_helper(substr($span, 0, -1), $lang);
1939
        };
1940
1941
        $rtrim1_htmlesc = function ($span, $lang, $ch) {
2 ignored issues
show
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1941
        $rtrim1_htmlesc = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $lang is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1941
        $rtrim1_htmlesc = function ($span, /** @scrutinizer ignore-unused */ $lang, $ch) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1942
            return htmlspecialchars(substr($span, 0, -1));
1943
        };
1944
1945
        $sch_rtrim1 = function ($span, $lang, $ch) use ($sch_syntax_helper) {
3 ignored issues
show
Unused Code introduced by
The assignment to $sch_rtrim1 is dead and can be removed.
Loading history...
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1945
        $sch_rtrim1 = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) use ($sch_syntax_helper) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $lang is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1945
        $sch_rtrim1 = function ($span, /** @scrutinizer ignore-unused */ $lang, $ch) use ($sch_syntax_helper) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1946
            return $sch_syntax_helper(substr($span, 0, -1));
1947
        };
1948
1949
        $rtrim2 = function ($span, $lang, $ch) {
3 ignored issues
show
Unused Code introduced by
The assignment to $rtrim2 is dead and can be removed.
Loading history...
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1949
        $rtrim2 = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $lang is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1949
        $rtrim2 = function ($span, /** @scrutinizer ignore-unused */ $lang, $ch) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1950
            return substr($span, 0, -2);
1951
        };
1952
1953
        $syn_proc = function ($span, $lang, $ch) use ($syntax_highlight_helper) {
1 ignored issue
show
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1953
        $syn_proc = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) use ($syntax_highlight_helper) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1954
            return $syntax_highlight_helper($span, $lang);
1955
        };
1956
1957
        $dash_putback = function ($span, $lang, $ch) use ($syntax_highlight_helper) {
1 ignored issue
show
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1957
        $dash_putback = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) use ($syntax_highlight_helper) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1958
            return $syntax_highlight_helper('-' . $span, $lang);
1959
        };
1960
1961
        $slash_putback = function ($span, $lang, $ch) use ($syntax_highlight_helper) {
1 ignored issue
show
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1961
        $slash_putback = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) use ($syntax_highlight_helper) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1962
            return $syntax_highlight_helper('/' . $span, $lang);
1963
        };
1964
1965
        $slash_putback_rtrim1 = function ($span, $lang, $ch) use ($rtrim1) {
1966
            return $rtrim1('/' . $span, $lang, $ch);
1967
        };
1968
1969
        $lparen_putback = function ($span, $lang, $ch) use ($syntax_highlight_helper) {
1 ignored issue
show
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1969
        $lparen_putback = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) use ($syntax_highlight_helper) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1970
            return $syntax_highlight_helper('(' . $span, $lang);
1971
        };
1972
1973
        $lparen_putback_rtrim1 = function ($span, $lang, $ch) use ($rtrim1) {
1974
            return $rtrim1('(' . $span, $lang, $ch);
1975
        };
1976
1977
        $prepend_xml_opentag = function ($span, $lang, $ch) {
2 ignored issues
show
Unused Code introduced by
The parameter $lang is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1977
        $prepend_xml_opentag = function ($span, /** @scrutinizer ignore-unused */ $lang, $ch) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1977
        $prepend_xml_opentag = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1978
            return '<span class="xml_tag">&lt;' . $span;
1979
        };
1980
1981
        $proc_void = function ($span, $lang, $ch) {
2 ignored issues
show
Unused Code introduced by
The parameter $lang is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1981
        $proc_void = function ($span, /** @scrutinizer ignore-unused */ $lang, $ch) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $ch is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1981
        $proc_void = function ($span, $lang, /** @scrutinizer ignore-unused */ $ch) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1982
            return $span;
1983
        };
1984
1985
        $this->sch[self::SCH_NORMAL][0]   = self::SCH_NORMAL;
1986
        $this->sch[self::SCH_NORMAL]['"'] = self::SCH_STRLIT;
1987
        $this->sch[self::SCH_NORMAL]['#'] = self::SCH_CHRLIT;
1988
        $this->sch[self::SCH_NORMAL]['0'] = self::SCH_NUMLIT;
1989
        $this->sch[self::SCH_NORMAL]['1'] = self::SCH_NUMLIT;
1990
        $this->sch[self::SCH_NORMAL]['2'] = self::SCH_NUMLIT;
1991
        $this->sch[self::SCH_NORMAL]['3'] = self::SCH_NUMLIT;
1992
        $this->sch[self::SCH_NORMAL]['4'] = self::SCH_NUMLIT;
1993
        $this->sch[self::SCH_NORMAL]['5'] = self::SCH_NUMLIT;
1994
        $this->sch[self::SCH_NORMAL]['6'] = self::SCH_NUMLIT;
1995
        $this->sch[self::SCH_NORMAL]['7'] = self::SCH_NUMLIT;
1996
        $this->sch[self::SCH_NORMAL]['8'] = self::SCH_NUMLIT;
1997
        $this->sch[self::SCH_NORMAL]['9'] = self::SCH_NUMLIT;
1998
1999
        $this->sch[self::SCH_STRLIT]['"']  = self::SCH_NORMAL;
2000
        $this->sch[self::SCH_STRLIT]["\n"] = self::SCH_NORMAL;
2001
        $this->sch[self::SCH_STRLIT]['\\'] = self::SCH_STRESC;
2002
        $this->sch[self::SCH_STRLIT][0]    = self::SCH_STRLIT;
2003
2004
        $this->sch[self::SCH_CHRLIT][' ']  = self::SCH_NORMAL;
2005
        $this->sch[self::SCH_CHRLIT]["\t"] = self::SCH_NORMAL;
2006
        $this->sch[self::SCH_CHRLIT]["\n"] = self::SCH_NORMAL;
2007
        $this->sch[self::SCH_CHRLIT]["\r"] = self::SCH_NORMAL;
2008
        $this->sch[self::SCH_CHRLIT][0]    = self::SCH_CHRLIT;
2009
2010
        $this->sch[self::SCH_NUMLIT][' ']  = self::SCH_NORMAL;
2011
        $this->sch[self::SCH_NUMLIT]["\t"] = self::SCH_NORMAL;
2012
        $this->sch[self::SCH_NUMLIT]["\n"] = self::SCH_NORMAL;
2013
        $this->sch[self::SCH_NUMLIT]["\r"] = self::SCH_NORMAL;
2014
        $this->sch[self::SCH_NUMLIT][0]    = self::SCH_NUMLIT;
2015
2016
        //
2017
        // State transitions for C
2018
        //
2019
        $this->c89[self::NORMAL_TEXT]['"'] = self::DQ_LITERAL;
2020
        $this->c89[self::NORMAL_TEXT]["'"] = self::SQ_LITERAL;
2021
        $this->c89[self::NORMAL_TEXT]['/'] = self::SLASH_BEGIN;
2022
        $this->c89[self::NORMAL_TEXT][0]   = self::NORMAL_TEXT;
2023
2024
        $this->c89[self::DQ_LITERAL]['"']  = self::NORMAL_TEXT;
2025
        $this->c89[self::DQ_LITERAL]["\n"] = self::NORMAL_TEXT;
2026
        $this->c89[self::DQ_LITERAL]['\\'] = self::DQ_ESCAPE;
2027
        $this->c89[self::DQ_LITERAL][0]    = self::DQ_LITERAL;
2028
2029
        $this->c89[self::DQ_ESCAPE][0] = self::DQ_LITERAL;
2030
2031
        $this->c89[self::SQ_LITERAL]["'"]  = self::NORMAL_TEXT;
2032
        $this->c89[self::SQ_LITERAL]["\n"] = self::NORMAL_TEXT;
2033
        $this->c89[self::SQ_LITERAL]['\\'] = self::SQ_ESCAPE;
2034
        $this->c89[self::SQ_LITERAL][0]    = self::SQ_LITERAL;
2035
2036
        $this->c89[self::SQ_ESCAPE][0] = self::SQ_LITERAL;
2037
2038
        $this->c89[self::SLASH_BEGIN]['*'] = self::STAR_COMMENT;
2039
        $this->c89[self::SLASH_BEGIN][0]   = self::NORMAL_TEXT;
2040
2041
        $this->c89[self::STAR_COMMENT]['*'] = self::STAR_END;
2042
        $this->c89[self::STAR_COMMENT][0]   = self::STAR_COMMENT;
2043
2044
        $this->c89[self::STAR_END]['/'] = self::NORMAL_TEXT;
2045
        $this->c89[self::STAR_END]['*'] = self::STAR_END;
2046
        $this->c89[self::STAR_END][0]   = self::STAR_COMMENT;
2047
2048
        //
2049
        // State transitions for C++
2050
        // Inherit transitions from C, and add line comment support
2051
        //
2052
        $this->cpp                           = $this->c89;
2053
        $this->cpp[self::SLASH_BEGIN]['/']   = self::LINE_COMMENT;
2054
        $this->cpp[self::LINE_COMMENT]["\n"] = self::NORMAL_TEXT;
2055
        $this->cpp[self::LINE_COMMENT]['\\'] = self::LC_ESCAPE;
2056
        $this->cpp[self::LINE_COMMENT][0]    = self::LINE_COMMENT;
2057
2058
        $this->cpp[self::LC_ESCAPE]["\r"] = self::LC_ESCAPE;
2059
        $this->cpp[self::LC_ESCAPE][0]    = self::LINE_COMMENT;
2060
2061
        //
2062
        // State transitions for C99.
2063
        // C99 supports line comments like C++
2064
        //
2065
        $this->c99 = $this->cpp;
2066
2067
        // State transitions for PL/I
2068
        // Kinda like C
2069
        $this->pli = $this->c89;
2070
2071
        //
2072
        // State transitions for PHP
2073
        // Inherit transitions from C++, and add perl-style line comment support
2074
        $this->php                         = $this->cpp;
2075
        $this->php[self::NORMAL_TEXT]['#'] = self::LINE_COMMENT;
2076
        $this->php[self::SQ_LITERAL]["\n"] = self::SQ_LITERAL;
2077
        $this->php[self::DQ_LITERAL]["\n"] = self::DQ_LITERAL;
2078
2079
        //
2080
        // State transitions for Perl
2081
        $this->perl[self::NORMAL_TEXT]['#'] = self::LINE_COMMENT;
2082
        $this->perl[self::NORMAL_TEXT]['"'] = self::DQ_LITERAL;
2083
        $this->perl[self::NORMAL_TEXT]["'"] = self::SQ_LITERAL;
2084
        $this->perl[self::NORMAL_TEXT][0]   = self::NORMAL_TEXT;
2085
2086
        $this->perl[self::DQ_LITERAL]['"']  = self::NORMAL_TEXT;
2087
        $this->perl[self::DQ_LITERAL]['\\'] = self::DQ_ESCAPE;
2088
        $this->perl[self::DQ_LITERAL][0]    = self::DQ_LITERAL;
2089
2090
        $this->perl[self::DQ_ESCAPE][0] = self::DQ_LITERAL;
2091
2092
        $this->perl[self::SQ_LITERAL]["'"]  = self::NORMAL_TEXT;
2093
        $this->perl[self::SQ_LITERAL]['\\'] = self::SQ_ESCAPE;
2094
        $this->perl[self::SQ_LITERAL][0]    = self::SQ_LITERAL;
2095
2096
        $this->perl[self::SQ_ESCAPE][0] = self::SQ_LITERAL;
2097
2098
        $this->perl[self::LINE_COMMENT]["\n"] = self::NORMAL_TEXT;
2099
        $this->perl[self::LINE_COMMENT][0]    = self::LINE_COMMENT;
2100
2101
        $this->mirc[self::NORMAL_TEXT]['"'] = self::DQ_LITERAL;
2102
        $this->mirc[self::NORMAL_TEXT][';'] = self::LINE_COMMENT;
2103
        $this->mirc[self::NORMAL_TEXT][0]   = self::NORMAL_TEXT;
2104
2105
        $this->mirc[self::DQ_LITERAL]['"']  = self::NORMAL_TEXT;
2106
        $this->mirc[self::DQ_LITERAL]['\\'] = self::DQ_ESCAPE;
2107
        $this->mirc[self::DQ_LITERAL][0]    = self::DQ_LITERAL;
2108
2109
        $this->mirc[self::DQ_ESCAPE][0] = self::DQ_LITERAL;
2110
2111
        $this->mirc[self::LINE_COMMENT]["\n"] = self::NORMAL_TEXT;
2112
        $this->mirc[self::LINE_COMMENT][0]    = self::LINE_COMMENT;
2113
2114
        $this->ruby = $this->perl;
2115
2116
        $this->python = $this->perl;
2117
2118
        $this->java = $this->cpp;
2119
2120
        $this->vb                         = $this->perl;
2121
        $this->vb[self::NORMAL_TEXT]['#'] = self::NORMAL_TEXT;
2122
        $this->vb[self::NORMAL_TEXT]["'"] = self::LINE_COMMENT;
2123
2124
        $this->cs = $this->java;
2125
2126
        $this->pascal                         = $this->c89;
2127
        $this->pascal[self::NORMAL_TEXT]['('] = self::PAREN_BEGIN;
2128
        $this->pascal[self::NORMAL_TEXT]['/'] = self::SLASH_BEGIN;
2129
        $this->pascal[self::NORMAL_TEXT]['{'] = self::BLOCK_COMMENT;
2130
2131
        $this->pascal[self::PAREN_BEGIN]['*'] = self::STAR_COMMENT;
2132
        $this->pascal[self::PAREN_BEGIN]["'"] = self::SQ_LITERAL;
2133
        $this->pascal[self::PAREN_BEGIN]['"'] = self::DQ_LITERAL;
2134
        $this->pascal[self::PAREN_BEGIN][0]   = self::NORMAL_TEXT;
2135
2136
        $this->pascal[self::SLASH_BEGIN]["'"] = self::SQ_LITERAL;
2137
        $this->pascal[self::SLASH_BEGIN]['"'] = self::DQ_LITERAL;
2138
        $this->pascal[self::SLASH_BEGIN]['/'] = self::LINE_COMMENT;
2139
        $this->pascal[self::SLASH_BEGIN][0]   = self::NORMAL_TEXT;
2140
2141
        $this->pascal[self::STAR_COMMENT]['*'] = self::STAR_END;
2142
        $this->pascal[self::STAR_COMMENT][0]   = self::STAR_COMMENT;
2143
2144
        $this->pascal[self::BLOCK_COMMENT]['}'] = self::NORMAL_TEXT;
2145
        $this->pascal[self::BLOCK_COMMENT][0]   = self::BLOCK_COMMENT;
2146
2147
        $this->pascal[self::LINE_COMMENT]["\n"] = self::NORMAL_TEXT;
2148
        $this->pascal[self::LINE_COMMENT][0]    = self::LINE_COMMENT;
2149
2150
        $this->pascal[self::STAR_END][')'] = self::NORMAL_TEXT;
2151
        $this->pascal[self::STAR_END]['*'] = self::STAR_END;
2152
        $this->pascal[self::STAR_END][0]   = self::STAR_COMMENT;
2153
2154
        $this->sql[self::NORMAL_TEXT]['"'] = self::DQ_LITERAL;
2155
        $this->sql[self::NORMAL_TEXT]["'"] = self::SQ_LITERAL;
2156
        $this->sql[self::NORMAL_TEXT]['`'] = self::BT_LITERAL;
2157
        $this->sql[self::NORMAL_TEXT]['-'] = self::DASH_BEGIN;
2158
        $this->sql[self::NORMAL_TEXT][0]   = self::NORMAL_TEXT;
2159
2160
        $this->sql[self::DQ_LITERAL]['"']  = self::NORMAL_TEXT;
2161
        $this->sql[self::DQ_LITERAL]['\\'] = self::DQ_ESCAPE;
2162
        $this->sql[self::DQ_LITERAL][0]    = self::DQ_LITERAL;
2163
2164
        $this->sql[self::SQ_LITERAL]["'"]  = self::NORMAL_TEXT;
2165
        $this->sql[self::SQ_LITERAL]['\\'] = self::SQ_ESCAPE;
2166
        $this->sql[self::SQ_LITERAL][0]    = self::SQ_LITERAL;
2167
2168
        $this->sql[self::BT_LITERAL]['`']  = self::NORMAL_TEXT;
2169
        $this->sql[self::BT_LITERAL]['\\'] = self::BT_ESCAPE;
2170
        $this->sql[self::BT_LITERAL][0]    = self::BT_LITERAL;
2171
2172
        $this->sql[self::DQ_ESCAPE][0] = self::DQ_LITERAL;
2173
        $this->sql[self::SQ_ESCAPE][0] = self::SQ_LITERAL;
2174
        $this->sql[self::BT_ESCAPE][0] = self::BT_LITERAL;
2175
2176
        $this->sql[self::DASH_BEGIN]['-'] = self::LINE_COMMENT;
2177
        $this->sql[self::DASH_BEGIN][0]   = self::NORMAL_TEXT;
2178
2179
        $this->sql[self::LINE_COMMENT]["\n"] = self::NORMAL_TEXT;
2180
        $this->sql[self::LINE_COMMENT]['\\'] = self::LC_ESCAPE;
2181
        $this->sql[self::LINE_COMMENT][0]    = self::LINE_COMMENT;
2182
2183
        $this->sql[self::LC_ESCAPE]["\r"] = self::LC_ESCAPE;
2184
        $this->sql[self::LC_ESCAPE][0]    = self::LINE_COMMENT;
2185
2186
        $this->xml[self::NORMAL_TEXT]['<']   = self::XML_TAG_BEGIN;
2187
        $this->xml[self::NORMAL_TEXT]['&']   = self::HTML_ENTITY;
2188
        $this->xml[self::NORMAL_TEXT][0]     = self::NORMAL_TEXT;
2189
        $this->xml[self::HTML_ENTITY][';']   = self::NORMAL_TEXT;
2190
        $this->xml[self::HTML_ENTITY]['<']   = self::XML_TAG_BEGIN;
2191
        $this->xml[self::HTML_ENTITY][0]     = self::HTML_ENTITY;
2192
        $this->xml[self::XML_TAG_BEGIN]['?'] = self::XML_PI;
2193
        $this->xml[self::XML_TAG_BEGIN]['!'] = self::LINE_COMMENT;
2194
        $this->xml[self::XML_TAG_BEGIN][0]   = self::XML_TAG;
2195
        $this->xml[self::XML_TAG]['>']       = self::NORMAL_TEXT;
2196
        $this->xml[self::XML_TAG]['"']       = self::DQ_LITERAL;
2197
        $this->xml[self::XML_TAG]["'"]       = self::SQ_LITERAL;
2198
        $this->xml[self::XML_TAG][0]         = self::XML_TAG;
2199
        $this->xml[self::XML_PI]['>']        = self::NORMAL_TEXT;
2200
        $this->xml[self::XML_PI][0]          = self::XML_TAG;
2201
        $this->xml[self::LINE_COMMENT]['>']  = self::NORMAL_TEXT;
2202
        $this->xml[self::LINE_COMMENT][0]    = self::LINE_COMMENT;
2203
        $this->xml[self::DQ_LITERAL]['"']    = self::XML_TAG;
2204
        $this->xml[self::DQ_LITERAL]['&']    = self::DQ_ESCAPE;
2205
        $this->xml[self::DQ_LITERAL][0]      = self::DQ_LITERAL;
2206
        $this->xml[self::SQ_LITERAL]["'"]    = self::XML_TAG;
2207
        $this->xml[self::SQ_LITERAL]['&']    = self::SQ_ESCAPE;
2208
        $this->xml[self::SQ_LITERAL][0]      = self::SQ_LITERAL;
2209
        $this->xml[self::DQ_ESCAPE][';']     = self::DQ_LITERAL;
2210
        $this->xml[self::DQ_ESCAPE][0]       = self::DQ_ESCAPE;
2211
2212
        //
2213
        // Main state transition table
2214
        //
2215
        $this->states = [
2216
            'C89'    => $this->c89,
2217
            'C'      => $this->c99,
2218
            'C++'    => $this->cpp,
2219
            'PHP'    => $this->php,
2220
            'Perl'   => $this->perl,
2221
            'Java'   => $this->java,
2222
            'VB'     => $this->vb,
2223
            'C#'     => $this->cs,
2224
            'Ruby'   => $this->ruby,
2225
            'Python' => $this->python,
2226
            'Pascal' => $this->pascal,
2227
            'mIRC'   => $this->mirc,
2228
            'PL/I'   => $this->pli,
2229
            'SQL'    => $this->sql,
2230
            'XML'    => $this->xml,
2231
            'Scheme' => $this->sch,
2232
        ];
2233
2234
        //
2235
        // Process functions
2236
        //
2237
        $this->process['C89'][self::NORMAL_TEXT][self::SQ_LITERAL]  = $rtrim1;
2238
        $this->process['C89'][self::NORMAL_TEXT][self::DQ_LITERAL]  = $rtrim1;
2239
        $this->process['C89'][self::NORMAL_TEXT][self::SLASH_BEGIN] = $rtrim1;
2240
        $this->process['C89'][self::NORMAL_TEXT][0]                 = $syn_proc;
2241
2242
        $this->process['C89'][self::SLASH_BEGIN][self::STAR_COMMENT] = $rtrim1;
2243
        $this->process['C89'][self::SLASH_BEGIN][0]                  = $slash_putback;
2244
2245
        $this->process['Scheme'][self::SCH_NORMAL][self::SCH_STRLIT] = $this;
2246
        $this->process['Scheme'][self::SCH_NORMAL][self::SCH_CHRLIT] = $this;
2247
        $this->process['Scheme'][self::SCH_NORMAL][self::SCH_NUMLIT] = $this;
2248
2249
        $this->process['SQL'][self::NORMAL_TEXT][self::SQ_LITERAL] = $rtrim1;
2250
        $this->process['SQL'][self::NORMAL_TEXT][self::DQ_LITERAL] = $rtrim1;
2251
        $this->process['SQL'][self::NORMAL_TEXT][self::BT_LITERAL] = $rtrim1;
2252
        $this->process['SQL'][self::NORMAL_TEXT][self::DASH_BEGIN] = $rtrim1;
2253
        $this->process['SQL'][self::NORMAL_TEXT][0]                = $syn_proc;
2254
2255
        $this->process['SQL'][self::DASH_BEGIN][self::LINE_COMMENT] = $rtrim1;
2256
        $this->process['SQL'][self::DASH_BEGIN][0]                  = $dash_putback;
2257
2258
        $this->process['PL/I'] = $this->process['C89'];
2259
2260
        $this->process['C++']                                        = $this->process['C89'];
2261
        $this->process['C++'][self::SLASH_BEGIN][self::LINE_COMMENT] = $rtrim1;
2262
2263
        $this->process['C'] = $this->process['C++'];
2264
2265
        $this->process['PHP']                                        = $this->process['C++'];
2266
        $this->process['PHP'][self::NORMAL_TEXT][self::LINE_COMMENT] = $rtrim1;
2267
2268
        $this->process['Perl'][self::NORMAL_TEXT][self::SQ_LITERAL]   = $rtrim1;
2269
        $this->process['Perl'][self::NORMAL_TEXT][self::DQ_LITERAL]   = $rtrim1;
2270
        $this->process['Perl'][self::NORMAL_TEXT][self::LINE_COMMENT] = $rtrim1;
2271
        $this->process['Perl'][self::NORMAL_TEXT][0]                  = $syn_proc;
2272
2273
        $this->process['Ruby']   = $this->process['Perl'];
2274
        $this->process['Python'] = $this->process['Perl'];
2275
2276
        $this->process['mIRC'][self::NORMAL_TEXT][self::DQ_LITERAL]   = $rtrim1;
2277
        $this->process['mIRC'][self::NORMAL_TEXT][self::LINE_COMMENT] = $rtrim1;
2278
        $this->process['mIRC'][self::NORMAL_TEXT][0]                  = $syn_proc;
2279
2280
        $this->process['VB'] = $this->process['Perl'];
2281
2282
        $this->process['Java'] = $this->process['C++'];
2283
2284
        $this->process['C#'] = $this->process['Java'];
2285
2286
        $this->process['Pascal']                                         = $this->process['C++'];
2287
        $this->process['Pascal'][self::NORMAL_TEXT][self::LINE_COMMENT]  = $rtrim1;
2288
        $this->process['Pascal'][self::NORMAL_TEXT][self::BLOCK_COMMENT] = $rtrim1;
2289
        $this->process['Pascal'][self::NORMAL_TEXT][self::PAREN_BEGIN]   = $rtrim1;
2290
        $this->process['Pascal'][self::SLASH_BEGIN][self::SQ_LITERAL]    = $slash_putback_rtrim1;
2291
        $this->process['Pascal'][self::SLASH_BEGIN][self::DQ_LITERAL]    = $slash_putback_rtrim1;
2292
        $this->process['Pascal'][self::SLASH_BEGIN][0]                   = $slash_putback;
2293
        $this->process['Pascal'][self::PAREN_BEGIN][self::SQ_LITERAL]    = $lparen_putback_rtrim1;
2294
        $this->process['Pascal'][self::PAREN_BEGIN][self::DQ_LITERAL]    = $lparen_putback_rtrim1;
2295
        $this->process['Pascal'][self::PAREN_BEGIN][self::STAR_COMMENT]  = $rtrim1;
2296
        $this->process['Pascal'][self::PAREN_BEGIN][0]                   = $lparen_putback;
2297
2298
        $this->process['XML'][self::NORMAL_TEXT][self::XML_TAG_BEGIN]  = $rtrim1;
2299
        $this->process['XML'][self::NORMAL_TEXT][self::HTML_ENTITY]    = $rtrim1;
2300
        $this->process['XML'][self::HTML_ENTITY][self::XML_TAG_BEGIN]  = $rtrim1;
2301
        $this->process['XML'][self::HTML_ENTITY][0]                    = $proc_void;
2302
        $this->process['XML'][self::XML_TAG_BEGIN][self::XML_TAG]      = $prepend_xml_opentag;
2303
        $this->process['XML'][self::XML_TAG_BEGIN][self::XML_PI]       = $rtrim1;
2304
        $this->process['XML'][self::XML_TAG_BEGIN][self::LINE_COMMENT] = $rtrim1;
2305
        $this->process['XML'][self::LINE_COMMENT][self::NORMAL_TEXT]   = $rtrim1_htmlesc;
2306
        $this->process['XML'][self::XML_TAG][self::NORMAL_TEXT]        = $rtrim1;
2307
        $this->process['XML'][self::XML_TAG][self::DQ_LITERAL]         = $rtrim1;
2308
        $this->process['XML'][self::DQ_LITERAL][self::XML_TAG]         = $rtrim1;
2309
        $this->process['XML'][self::DQ_LITERAL][self::DQ_ESCAPE]       = $rtrim1;
2310
2311
        $this->process_end['C89']    = $syntax_highlight_helper;
2312
        $this->process_end['C++']    = $this->process_end['C89'];
2313
        $this->process_end['C']      = $this->process_end['C89'];
2314
        $this->process_end['PHP']    = $this->process_end['C89'];
2315
        $this->process_end['Perl']   = $this->process_end['C89'];
2316
        $this->process_end['Java']   = $this->process_end['C89'];
2317
        $this->process_end['VB']     = $this->process_end['C89'];
2318
        $this->process_end['C#']     = $this->process_end['C89'];
2319
        $this->process_end['Ruby']   = $this->process_end['C89'];
2320
        $this->process_end['Python'] = $this->process_end['C89'];
2321
        $this->process_end['Pascal'] = $this->process_end['C89'];
2322
        $this->process_end['mIRC']   = $this->process_end['C89'];
2323
        $this->process_end['PL/I']   = $this->process_end['C89'];
2324
        $this->process_end['SQL']    = $this->process_end['C89'];
2325
        $this->process_end['Scheme'] = $sch_syntax_helper;
2326
2327
        $this->edges['C89'][self::NORMAL_TEXT . ',' . self::DQ_LITERAL]   = '<span class="literal">"';
2328
        $this->edges['C89'][self::NORMAL_TEXT . ',' . self::SQ_LITERAL]   = '<span class="literal">\'';
2329
        $this->edges['C89'][self::SLASH_BEGIN . ',' . self::STAR_COMMENT] = '<span class="comment">/*';
2330
        $this->edges['C89'][self::DQ_LITERAL . ',' . self::NORMAL_TEXT]   = '</span>';
2331
        $this->edges['C89'][self::SQ_LITERAL . ',' . self::NORMAL_TEXT]   = '</span>';
2332
        $this->edges['C89'][self::STAR_END . ',' . self::NORMAL_TEXT]     = '</span>';
2333
2334
        $this->edges['Scheme'][self::SCH_NORMAL . ',' . self::SCH_STRLIT] = '<span class="sch_str">"';
2335
        $this->edges['Scheme'][self::SCH_NORMAL . ',' . self::SCH_NUMLIT] = '<span class="sch_num">';
2336
        $this->edges['Scheme'][self::SCH_NORMAL . ',' . self::SCH_CHRLIT] = '<span class="sch_chr">#';
2337
        $this->edges['Scheme'][self::SCH_STRLIT . ',' . self::SCH_NORMAL] = '</span>';
2338
        $this->edges['Scheme'][self::SCH_NUMLIT . ',' . self::SCH_NORMAL] = '</span>';
2339
        $this->edges['Scheme'][self::SCH_CHRLIT . ',' . self::SCH_NORMAL] = '</span>';
2340
2341
        $this->edges['SQL'][self::NORMAL_TEXT . ',' . self::DQ_LITERAL]   = '<span class="literal">"';
2342
        $this->edges['SQL'][self::NORMAL_TEXT . ',' . self::SQ_LITERAL]   = '<span class="literal">\'';
2343
        $this->edges['SQL'][self::DASH_BEGIN . ',' . self::LINE_COMMENT]  = '<span class="comment">--';
2344
        $this->edges['SQL'][self::NORMAL_TEXT . ',' . self::BT_LITERAL]   = '`';
2345
        $this->edges['SQL'][self::DQ_LITERAL . ',' . self::NORMAL_TEXT]   = '</span>';
2346
        $this->edges['SQL'][self::SQ_LITERAL . ',' . self::NORMAL_TEXT]   = '</span>';
2347
        $this->edges['SQL'][self::LINE_COMMENT . ',' . self::NORMAL_TEXT] = '</span>';
2348
2349
        $this->edges['PL/I'] = $this->edges['C89'];
2350
2351
        $this->edges['C++']                                               = $this->edges['C89'];
2352
        $this->edges['C++'][self::SLASH_BEGIN . ',' . self::LINE_COMMENT] = '<span class="comment">//';
2353
        $this->edges['C++'][self::LINE_COMMENT . ',' . self::NORMAL_TEXT] = '</span>';
2354
2355
        $this->edges['C'] = $this->edges['C++'];
2356
2357
        $this->edges['PHP']                                               = $this->edges['C++'];
2358
        $this->edges['PHP'][self::NORMAL_TEXT . ',' . self::LINE_COMMENT] = '<span class="comment">#';
2359
2360
        $this->edges['Perl'][self::NORMAL_TEXT . ',' . self::DQ_LITERAL]   = '<span class="literal">"';
2361
        $this->edges['Perl'][self::NORMAL_TEXT . ',' . self::SQ_LITERAL]   = '<span class="literal">\'';
2362
        $this->edges['Perl'][self::DQ_LITERAL . ',' . self::NORMAL_TEXT]   = '</span>';
2363
        $this->edges['Perl'][self::SQ_LITERAL . ',' . self::NORMAL_TEXT]   = '</span>';
2364
        $this->edges['Perl'][self::NORMAL_TEXT . ',' . self::LINE_COMMENT] = '<span class="comment">#';
2365
        $this->edges['Perl'][self::LINE_COMMENT . ',' . self::NORMAL_TEXT] = '</span>';
2366
2367
        $this->edges['Ruby'] = $this->edges['Perl'];
2368
2369
        $this->edges['Python'] = $this->edges['Perl'];
2370
2371
        $this->edges['mIRC'][self::NORMAL_TEXT . ',' . self::DQ_LITERAL]   = '<span class="literal">"';
2372
        $this->edges['mIRC'][self::NORMAL_TEXT . ',' . self::LINE_COMMENT] = '<span class="comment">;';
2373
        $this->edges['mIRC'][self::DQ_LITERAL . ',' . self::NORMAL_TEXT]   = '</span>';
2374
        $this->edges['mIRC'][self::LINE_COMMENT . ',' . self::NORMAL_TEXT] = '</span>';
2375
2376
        $this->edges['VB']                                               = $this->edges['Perl'];
2377
        $this->edges['VB'][self::NORMAL_TEXT . ',' . self::LINE_COMMENT] = '<span class="comment">\'';
2378
2379
        $this->edges['Java'] = $this->edges['C++'];
2380
2381
        $this->edges['C#'] = $this->edges['Java'];
2382
2383
        $this->edges['Pascal']                                                = $this->edges['C89'];
2384
        $this->edges['Pascal'][self::PAREN_BEGIN . ',' . self::STAR_COMMENT]  = '<span class="comment">(*';
2385
        $this->edges['Pascal'][self::PAREN_BEGIN . ',' . self::DQ_LITERAL]    = '<span class="literal">"';
2386
        $this->edges['Pascal'][self::PAREN_BEGIN . ',' . self::SQ_LITERAL]    = '<span class="literal">\'';
2387
        $this->edges['Pascal'][self::SLASH_BEGIN . ',' . self::DQ_LITERAL]    = '<span class="literal">"';
2388
        $this->edges['Pascal'][self::SLASH_BEGIN . ',' . self::SQ_LITERAL]    = '<span class="literal">\'';
2389
        $this->edges['Pascal'][self::SLASH_BEGIN . ',' . self::LINE_COMMENT]  = '<span class="comment">//';
2390
        $this->edges['Pascal'][self::NORMAL_TEXT . ',' . self::BLOCK_COMMENT] = '<span class="comment">{';
2391
        $this->edges['Pascal'][self::LINE_COMMENT . ',' . self::NORMAL_TEXT]  = '</span>';
2392
        $this->edges['Pascal'][self::BLOCK_COMMENT . ',' . self::NORMAL_TEXT] = '</span>';
2393
2394
        $this->edges['XML'][self::NORMAL_TEXT . ',' . self::HTML_ENTITY]    = '<span class="html_entity">&amp;';
2395
        $this->edges['XML'][self::HTML_ENTITY . ',' . self::NORMAL_TEXT]    = '</span>';
2396
        $this->edges['XML'][self::HTML_ENTITY . ',' . self::XML_TAG_BEGIN]  = '</span>';
2397
        $this->edges['XML'][self::XML_TAG . ',' . self::NORMAL_TEXT]        = '&gt;</span>';
2398
        $this->edges['XML'][self::XML_TAG_BEGIN . ',' . self::XML_PI]       = '<span class="xml_pi">&lt;?';
2399
        $this->edges['XML'][self::XML_TAG_BEGIN . ',' . self::LINE_COMMENT] = '<span class="comment">&lt;!';
2400
        $this->edges['XML'][self::LINE_COMMENT . ',' . self::NORMAL_TEXT]   = '&gt;</span>';
2401
        $this->edges['XML'][self::XML_TAG . ',' . self::DQ_LITERAL]         = '<span class="literal">"';
2402
        $this->edges['XML'][self::DQ_LITERAL . ',' . self::XML_TAG]         = '"</span>';
2403
        $this->edges['XML'][self::DQ_LITERAL . ',' . self::DQ_ESCAPE]       = '<span class="html_entity">&amp;';
2404
        $this->edges['XML'][self::DQ_ESCAPE . ',' . self::DQ_LITERAL]       = '</span>';
2405
        $this->edges['XML'][self::XML_TAG . ',' . self::SQ_LITERAL]         = '<span class="literal">\'';
2406
        $this->edges['XML'][self::SQ_LITERAL . ',' . self::XML_TAG]         = '\'</span>';
2407
        $this->edges['XML'][self::SQ_LITERAL . ',' . self::SQ_ESCAPE]       = '<span class="html_entity">&amp;';
2408
        $this->edges['XML'][self::SQ_ESCAPE . ',' . self::SQ_LITERAL]       = '</span>';
2409
    }
2410
2411
    /**
2412
     * Syntax highlight function
2413
     * Does the bulk of the syntax highlighting by lexing the input
2414
     * string, then calling the helper function to highlight keywords.
2415
     *
2416
     * @param $text
2417
     * @param $language
2418
     * @return string
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
2419
     */
2420
    public function syntax_highlight($text, $language)
1 ignored issue
show
Coding Style introduced by
Public method name "Highlight::syntax_highlight" is not in camel caps format
Loading history...
2421
    {
2422
        if ($language == 'Plain Text') {
2423
            return $text;
2424
        }
2425
2426
        //
2427
        // The State Machine
2428
        //
2429
        if (array_key_exists($language, $this->initial_state)) {
2430
            $state = $this->initial_state[$language];
2431
        } else {
2432
            $state = self::NORMAL_TEXT;
2433
        }
2434
2435
        $output = '';
2436
        $span   = '';
2437
        while (strlen($text) > 0) {
2438
            $ch   = substr($text, 0, 1);
2439
            $text = substr($text, 1);
2440
2441
            $oldstate = $state;
2442
            $state    = array_key_exists($ch, $this->states[$language][$state]) ?
2443
            $this->states[$language][$state][$ch] :
2444
            $this->states[$language][$state][0];
2445
2446
            $span .= $ch;
2447
2448
            if ($oldstate != $state) {
2449
                if (array_key_exists($language, $this->process) &&
2450
                    array_key_exists($oldstate, $this->process[$language])) {
2 ignored issues
show
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
2451
                    if (array_key_exists($state, $this->process[$language][$oldstate])) {
2452
                        $pf = $this->process[$language][$oldstate][$state];
2453
                        $output .= $pf($span, $language, $ch);
2454
                    } else {
2455
                        $pf = $this->process[$language][$oldstate][0];
2456
                        $output .= $pf($span, $language, $ch);
2457
                    }
2458
                } else {
2459
                    $output .= $span;
2460
                }
2461
2462
                if (array_key_exists($language, $this->edges) &&
2463
                    array_key_exists("$oldstate,$state", $this->edges[$language])) {
2 ignored issues
show
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
2464
                    $output .= $this->edges[$language]["$oldstate,$state"];
2465
                }
2466
2467
                $span = '';
2468
            }
2469
        }
2470
2471
        if (array_key_exists($language, $this->process_end) && $state == self::NORMAL_TEXT) {
2472
            $output .= $this->process_end[$language]($span, $language);
2473
        } else {
2474
            $output .= $span;
2475
        }
2476
2477
        if ($state != self::NORMAL_TEXT) {
2478
            if (array_key_exists($language, $this->edges) &&
2479
                array_key_exists("$state," . self::NORMAL_TEXT, $this->edges[$language])) {
2 ignored issues
show
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
2480
                $output .= $this->edges[$language]["$state," . self::NORMAL_TEXT];
2481
            }
2482
        }
2483
2484
        return $output;
2485
    }
2486
}
2487