1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
This file is part of the TDE project
Copyright (C) 2001, 2002, 2003, 2004 Anders Lund <anders@alweb.dk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*** NOTICE ***
This file is maintained by Anders Lund <anders@alweb.dk>
Please do not commit changes without checking with me.
*** TODO ***
Work on the comment support in the REPLACEMENT part of s/// - we may support
the comment, if the line remainder does not contain the delimiter char.
Try to support ?PATTERN? (at least in one line, like if "\?(?=.*\?)" matches).
parse code behind '<<HEREDELIMITER' as code, or at least ignore it, to eol.
Requires the ability to pass the delimiter through a context level.
find a here delimiter like '*END*' (Shell.pm). Requires that when a regex is
inserting a dynamic string, it escapes [*(){}$[]
support for more regex extensions, such as (?>), (?{}), (?(cond)yes|no)
Enhance tr/// and y/// support.
-->
<language name="Perl" version="2-1" kateversion="2.4" section="Scripts" extensions="*.pl;*.PL;*.pm" mimetype="application/x-perl;text/x-perl" priority="5" author="Anders Lund (anders@alweb.dk)" license="LGPL">
<highlighting>
<list name="keywords">
<item> if </item>
<item> unless </item>
<item> else </item>
<item> elsif </item>
<item> while </item>
<item> until </item>
<item> for </item>
<item> each </item>
<item> foreach </item>
<item> next </item>
<item> last </item>
<item> break </item>
<item> continue </item>
<item> return </item>
<item> my </item>
<item> our </item>
<item> local </item>
<item> state </item>
<item> BEGIN </item>
<item> END </item>
<item> package </item>
<item> sub </item>
<item> do </item>
<item> given </item>
<item> when </item>
<item> default </item>
<item> __END__ </item>
<item> __DATA__ </item>
<item> __FILE__ </item>
<item> __LINE__ </item>
<item> __PACKAGE__ </item>
</list>
<list name="operators">
<item> = </item>
<item> != </item>
<item> ~= </item>
<item> += </item>
<item> -= </item>
<item> *= </item>
<item> /= </item>
<item> **= </item>
<item> |= </item>
<item> ||= </item>
<item> //= </item>
<item> &= </item>
<item> &&= </item>
<item> ?= </item>
<item> + </item>
<item> - </item>
<item> * </item>
<!-- <item> / </item>//-->
<item> % </item>
<item> || </item>
<item> // </item>
<item> && </item>
<item> | </item>
<item> & </item>
<item> < </item>
<item> << </item>
<item> > </item>
<item> >> </item>
<item> ^ </item>
<item> -> </item>
<item> => </item>
<item> . </item>
<item> , </item>
<item> ; </item>
<item> :: </item>
<item> \ </item>
<item> and </item>
<item> or </item>
<item> not </item>
<item> eq </item>
<item> ne </item>
<item> lt </item>
<item> gt </item>
<item> le </item>
<item> ge </item>
<item> cmp </item>
</list>
<list name="functions">
<item>abs</item>
<item>accept</item>
<item>alarm</item>
<item>atan2</item>
<item>bind</item>
<item>binmode</item>
<item>bless</item>
<item>caller</item>
<item>chdir</item>
<item>chmod</item>
<item>chomp</item>
<item>chop</item>
<item>chown</item>
<item>chr</item>
<item>chroot</item>
<item>close</item>
<item>closedir</item>
<item>connect</item>
<item>cos</item>
<item>crypt</item>
<item>dbmclose</item>
<item>dbmopen</item>
<item>defined</item>
<item>delete</item>
<item>die</item>
<item>dump</item>
<item>endgrent</item>
<item>endhostent</item>
<item>endnetent</item>
<item>endprotoent</item>
<item>endpwent</item>
<item>endservent</item>
<item>eof</item>
<item>eval</item>
<item>exec</item>
<item>exists</item>
<item>exit</item>
<item>exp</item>
<item>fcntl</item>
<item>fileno</item>
<item>flock</item>
<item>fork</item>
<item>format</item>
<item>formline</item>
<item>getc</item>
<item>getgrent</item>
<item>getgrgid</item>
<item>getgrnam</item>
<item>gethostbyaddr</item>
<item>gethostbyname</item>
<item>gethostent</item>
<item>getlogin</item>
<item>getnetbyaddr</item>
<item>getnetbyname</item>
<item>getnetent</item>
<item>getpeername</item>
<item>getpgrp</item>
<item>getppid</item>
<item>getpriority</item>
<item>getprotobyname</item>
<item>getprotobynumber</item>
<item>getprotoent</item>
<item>getpwent</item>
<item>getpwnam</item>
<item>getpwuid</item>
<item>getservbyname</item>
<item>getservbyport</item>
<item>getservent</item>
<item>getsockname</item>
<item>getsockopt</item>
<item>glob</item>
<item>gmtime</item>
<item>goto</item>
<item>grep</item>
<item>hex</item>
<item>import</item>
<item>index</item>
<item>int</item>
<item>ioctl</item>
<item>join</item>
<item>keys</item>
<item>kill</item>
<item>last</item>
<item>lc</item>
<item>lcfirst</item>
<item>length</item>
<item>link</item>
<item>listen</item>
<item>localtime</item>
<item>lock</item>
<item>log</item>
<item>lstat</item>
<item>map</item>
<item>mkdir</item>
<item>msgctl</item>
<item>msgget</item>
<item>msgrcv</item>
<item>msgsnd</item>
<item>no</item>
<item>oct</item>
<item>open</item>
<item>opendir</item>
<item>ord</item>
<item>pack</item>
<item>package</item>
<item>pipe</item>
<item>pop</item>
<item>pos</item>
<item>print</item>
<item>printf</item>
<item>prototype</item>
<item>push</item>
<item>quotemeta</item>
<item>rand</item>
<item>read</item>
<item>readdir</item>
<item>readline</item>
<item>readlink</item>
<item>recv</item>
<item>redo</item>
<item>ref</item>
<item>rename</item>
<item>require</item>
<item>reset</item>
<item>return</item>
<item>reverse</item>
<item>rewinddir</item>
<item>rindex</item>
<item>rmdir</item>
<item>scalar</item>
<item>seek</item>
<item>seekdir</item>
<item>select</item>
<item>semctl</item>
<item>semget</item>
<item>semop</item>
<item>send</item>
<item>setgrent</item>
<item>sethostent</item>
<item>setnetent</item>
<item>setpgrp</item>
<item>setpriority</item>
<item>setprotoent</item>
<item>setpwent</item>
<item>setservent</item>
<item>setsockopt</item>
<item>shift</item>
<item>shmctl</item>
<item>shmget</item>
<item>shmread</item>
<item>shmwrite</item>
<item>shutdown</item>
<item>sin</item>
<item>sleep</item>
<item>socket</item>
<item>socketpair</item>
<item>sort</item>
<item>splice</item>
<item>split</item>
<item>sprintf</item>
<item>sqrt</item>
<item>srand</item>
<item>stat</item>
<item>study</item>
<item>sub</item>
<item>substr</item>
<item>symlink</item>
<item>syscall</item>
<item>sysread</item>
<item>sysseek</item>
<item>system</item>
<item>syswrite</item>
<item>tell</item>
<item>telldir</item>
<item>tie</item>
<item>time</item>
<item>times</item>
<item>truncate</item>
<item>uc</item>
<item>ucfirst</item>
<item>umask</item>
<item>undef</item>
<item>unlink</item>
<item>unpack</item>
<item>unshift</item>
<item>untie</item>
<item>use</item>
<item>utime</item>
<item>values</item>
<item>vec</item>
<item>wait</item>
<item>waitpid</item>
<item>wantarray</item>
<item>warn</item>
<item>write</item>
</list>
<list name="pragmas">
<item>strict</item>
<item>english</item>
<item>warnings</item>
<item>vars</item>
<item>subs</item>
<item>utf8</item>
<item>sigtrap</item>
<item>locale</item>
<item>open</item>
<item>less</item>
<item>integer</item>
<item>filetest</item>
<item>constant</item>
<item>bytes</item>
<item>diagnostics</item>
</list>
<contexts>
<context name="normal" attribute="Normal Text" lineEndContext="#stay">
<RegExpr attribute="Keyword" context="#stay" String="^#!\/.*" />
<StringDetect attribute="Keyword" context="data_handle" String="__DATA__" firstNonSpace="true" />
<StringDetect attribute="Keyword" context="#stay" String="__END__" firstNonSpace="true"/>
<RegExpr attribute="Keyword" context="sub_name_def" String="\bsub\s+" />
<keyword attribute="Keyword" context="#stay" String="keywords" />
<keyword attribute="Operator" context="#stay" String="operators" />
<keyword attribute="Function" context="#stay" String="functions" />
<keyword attribute="Pragma" context="#stay" String="pragmas" />
<RegExpr attribute="Pod" context="pod" String="\=\w+(\s|$)" column="0" beginRegion="POD"/>
<DetectSpaces />
<DetectChar attribute="Comment" context="comment" char="#" />
<!-- Numeric values. Note that we have to allow underscores between two digits (thus the creepy regular expressions). -->
<RegExpr attribute="Hex" String="\b\-?0[xX]([0-9a-fA-F]|_[0-9a-fA-F])+" context="slash_safe_escape"/>
<RegExpr attribute="Bin" String="\b\-?0[bB]([01]|_[01])+" context="slash_safe_escape"/>
<RegExpr attribute="Octal" String="\b\-?0[1-7]([0-7]|_[0-7])*" context="slash_safe_escape"/>
<RegExpr attribute="Float" String="\b\-?[0-9]([0-9]|_[0-9])*\.[0-9]([0-9]|_[0-9])*([eE]\-?[1-9]([0-9]|_[0-9])*(\.[0-9]*)?)?" context="slash_safe_escape"/>
<RegExpr attribute="Decimal" String="\b\-?[1-9]([0-9]|_[0-9])*\b" context="slash_safe_escape"/>
<Int attribute="Decimal" context="slash_safe_escape" />
<RegExpr attribute="Normal Text" context="#stay" String="\\(["'])[^\1]" />
<Detect2Chars attribute="Normal Text" context="#stay" char="&" char1="'" /><!-- ??? -->
<DetectChar attribute="Operator" context="ip_string" char=""" beginRegion="String" />
<DetectChar attribute="Operator" context="string" char="'" beginRegion="String"/>
<DetectChar attribute="Operator" context="Backticked" char="`" />
<RegExpr attribute="Normal Text" context="find_variable" String="(?:[$@]\S|%[\w{]|\*[^\d\*{\$@%=(])" lookAhead="true" />
<RegExpr attribute="Keyword" context="#stay" String="<[A-Z0-9_]+>" />
<RegExpr attribute="Operator" context="find_here_document" String="\s*<<(?=\w+|\s*["'])" beginRegion="HereDocument" />
<RegExpr attribute="Normal Text" context="#stay" String="\s*\}\s*/{1,2}" endRegion="Block"/>
<RegExpr attribute="Normal Text" context="#stay" String="\s*[)\]]\s*/{1,2}" />
<RegExpr attribute="Function" context="sub_name_def" String="\w+::" />
<RegExpr attribute="Normal Text" context="#stay" String="\w+[=]" />
<RegExpr attribute="Operator" context="find_quoted" String="\bq(?=[qwx]?\s*[^\w\s])" />
<RegExpr attribute="Operator" context="find_subst" String="\bs(?=\s*[^\w\s\]})])" />
<RegExpr attribute="Operator" context="tr" String="\b(?:tr|y)\s*(?=[^\w\s\]})])" />
<RegExpr attribute="Operator" context="find_pattern" String="\b(?:m|qr)(?=\s*[^\w\s\]})])" />
<RegExpr attribute="Normal Text" context="#stay" String="[\w_]+\s*/" />
<RegExpr attribute="Normal Text" context="#stay" String="[<>"':]/" />
<DetectChar attribute="Operator" context="pattern_slash" char="/" beginRegion="Pattern" />
<RegExpr attribute="Operator" context="#stay" String="-[rwxoRWXOeszfdlpSbctugkTBMAC]\b" />
<DetectChar attribute="Normal Text" context="#stay" char="{" beginRegion="Block" />
<DetectChar attribute="Normal Text" context="#stay" char="}" endRegion="Block" />
</context>
<!-- ====== quoted construct central ===== -->
<context name="find_quoted" attribute="Normal Text" lineEndContext="#stay" >
<!-- NOTE - qx'not interpolated regex' does not cover newline between "qr" and "'" -->
<RegExpr attribute="Operator" context="string_6" String="x\s*(')" beginRegion="String" />
<AnyChar attribute="Operator" context="find_qqx" String="qx" />
<DetectChar attribute="Operator" context="find_qw" char="w" />
<DetectChar attribute="Operator" context="string_2" char="(" beginRegion="String" />
<DetectChar attribute="Operator" context="string_3" char="{" beginRegion="String" />
<DetectChar attribute="Operator" context="string_4" char="[" beginRegion="String" />
<DetectChar attribute="Operator" context="string_5" char="<" beginRegion="String" />
<RegExpr attribute="Operator" context="string_6" String="([^a-zA-Z0-9_\s[\]{}()])" beginRegion="String" />
<RegExpr attribute="Comment" context="#stay" String="\s+#.*" /><!-- q[qwx] # == comment, look for the delim on the next line -->
</context>
<context name="find_qqx" attribute="Normal Text" lineEndContext="#stay" >
<DetectChar attribute="Operator" context="ip_string_2" char="(" beginRegion="String" />
<DetectChar attribute="Operator" context="ip_string_3" char="{" beginRegion="String" />
<DetectChar attribute="Operator" context="ip_string_4" char="[" beginRegion="String" />
<DetectChar attribute="Operator" context="ip_string_5" char="<" beginRegion="String" />
<RegExpr attribute="Operator" context="ip_string_6" String="([^a-zA-Z0-9_\s[\]{}()])" beginRegion="String" />
<RegExpr attribute="Comment" context="#stay" String="\s+#.*" /><!-- q[qwx] # == comment, look for the delim on the next line -->
</context>
<context name="find_qw" attribute="Normal Text" lineEndContext="#stay" >
<DetectChar attribute="Operator" context="quote_word_paren" char="(" beginRegion="Wordlist" />
<DetectChar attribute="Operator" context="quote_word_brace" char="{" beginRegion="Wordlist" />
<DetectChar attribute="Operator" context="quote_word_bracket" char="[" beginRegion="Wordlist" />
<RegExpr attribute="Operator" context="quote_word" String="([^a-zA-Z0-9_\s[\]{}()])" beginRegion="Wordlist" />
<RegExpr attribute="Comment" context="#stay" String="\s+#.*" /><!-- q[qwx] # == comment, look for the delim on the next line -->
</context>
<!-- ====== Contexts for strings ===== -->
<context name="ipstring_internal" attribute="String (interpolated)" lineEndContext="#stay">
<DetectIdentifier />
<RegExpr attribute="String Special Character" context="#stay" String="\\[UuLlEtnaefr]" />
<RegExpr attribute="String (interpolated)" context="#stay" String="\\." />
<RegExpr attribute="Normal Text" context="find_variable_unsafe" String="(?:[\$@]\S|%[\w{])" lookAhead="true" />
</context>
<context name="ip_string" attribute="String (interpolated)" lineEndContext="#stay">
<DetectChar attribute="Operator" context="#pop" char=""" endRegion="String"/>
<IncludeRules context="ipstring_internal" />
</context>
<context name="ip_string_2" attribute="String (interpolated)" lineEndContext="#stay">
<RangeDetect attribute="String (interpolated)" context="#stay" char="(" char1=")" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char=")" endRegion="String" />
<IncludeRules context="ipstring_internal" />
</context>
<context name="ip_string_3" attribute="String (interpolated)" lineEndContext="#stay">
<RangeDetect attribute="String (interpolated)" context="#stay" char="{" char1="}" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char="}" endRegion="String" />
<IncludeRules context="ipstring_internal" />
</context>
<context name="ip_string_4" attribute="String (interpolated)" lineEndContext="#stay">
<RangeDetect attribute="String (interpolated)" context="#stay" char="[" char1="]" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char="]" endRegion="String" />
<IncludeRules context="ipstring_internal" />
</context>
<context name="ip_string_5" attribute="String (interpolated)" lineEndContext="#stay">
<RangeDetect attribute="String (interpolated)" context="#stay" char="<" char1=">" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char=">" endRegion="String" />
<IncludeRules context="ipstring_internal" />
</context>
<context name="ip_string_6" attribute="String (interpolated)" lineEndContext="#stay" dynamic="true">
<RegExpr attribute="String (interpolated)" context="#stay" String="\%1" dynamic="true" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char="1" dynamic="true" endRegion="String"/>
<IncludeRules context="ipstring_internal" />
</context>
<context name="string" attribute="String" lineEndContext="#stay">
<DetectIdentifier />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="'" />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="\" />
<DetectChar attribute="Operator" context="#pop" char="'" endRegion="String" />
</context>
<context name="string_2" attribute="String" lineEndContext="#stay">
<DetectIdentifier />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1=")" />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="\" />
<RangeDetect attribute="String" context="#stay" char="(" char1=")" />
<DetectChar attribute="Operator" context="#pop#pop" char=")" endRegion="String" />
</context>
<context name="string_3" attribute="String" lineEndContext="#stay">
<DetectIdentifier />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="}" />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="\" />
<RangeDetect attribute="String" context="#stay" char="{" char1="}" />
<DetectChar attribute="Operator" context="#pop#pop" char="}" endRegion="String" />
</context>
<context name="string_4" attribute="String" lineEndContext="#stay">
<DetectIdentifier />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="]" />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="\" />
<RangeDetect attribute="String" context="#stay" char="[" char1="]" />
<DetectChar attribute="Operator" context="#pop#pop" char="]" endRegion="String" />
</context>
<context name="string_5" attribute="String" lineEndContext="#stay">
<DetectIdentifier />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="<" />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="\" />
<Detect2Chars attribute="String" context="#stay" char="\" char1=">" />
<RangeDetect attribute="String" context="#stay" char="<" char1=">" />
<DetectChar attribute="Operator" context="#pop#pop" char=">" endRegion="String" />
</context>
<context name="string_6" attribute="String" lineEndContext="#stay" dynamic="true">
<DetectIdentifier />
<Detect2Chars attribute="String Special Character" context="#stay" char="\" char1="\" />
<RegExpr attribute="String Special Character" context="#stay" String="\%1" dynamic="true"/>
<DetectChar attribute="Operator" context="#pop#pop" char="1" dynamic="true" endRegion="String" />
</context>
<!-- ====== contexts for s/// ====== -->
<context name="find_subst" attribute="Normal Text" lineEndContext="#stay" >
<RegExpr attribute="Comment" context="#stay" String="\s+#.*" /><!-- s # == comment, look for the delim on the next line -->
<DetectChar attribute="Operator" context="subst_curlybrace_pattern" char="{" beginRegion="Pattern" />
<DetectChar attribute="Operator" context="subst_paren_pattern" char="(" beginRegion="Pattern" />
<DetectChar attribute="Operator" context="subst_bracket_pattern" char="[" beginRegion="Pattern" />
<DetectChar attribute="Operator" context="subst_sq_pattern" char="'" beginRegion="Pattern" />
<RegExpr attribute="Operator" context="subst_slash_pattern" String="([^\w\s[\]{}()])" beginRegion="Pattern" />
</context>
<!-- Fully parse s {} {}.
This means that
- comments are legal between PATTERN and REPLACEMENT
- REPLACEMENT can contain resursive {} blocks -->
<context name="subst_curlybrace_pattern" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Comment" context="#stay" String="\s+#.*$" />
<IncludeRules context="regex_pattern_internal_ip" />
<DetectChar attribute="Operator" context="subst_curlybrace_middle" char="}" endRegion="Pattern" />
</context>
<context name="subst_curlybrace_middle" attribute="Normal Text" lineEndContext="#stay" >
<RegExpr attribute="Comment" context="#stay" String="#.*$" />
<DetectChar attribute="Operator" context="subst_curlybrace_replace" char="{" beginRegion="Replacement" />
</context>
<context name="subst_curlybrace_replace" attribute="String (interpolated)" lineEndContext="#stay">
<IncludeRules context="ipstring_internal" />
<DetectChar attribute="Normal Text" context="subst_curlybrace_replace_recursive" char="{" beginRegion="Block" />
<RegExpr attribute="Operator" context="#pop#pop#pop#pop" String="\}[cegimosx]*" endRegion="Replacement" />
</context>
<context name="subst_curlybrace_replace_recursive" attribute="String (interpolated)" lineEndContext="#stay" >
<DetectChar attribute="String (interpolated)" context="subst_curlybrace_replace_recursive" char="{" beginRegion="Block" />
<DetectChar attribute="Normal Text" context="#pop" char="}" endRegion="Block" />
<IncludeRules context="ipstring_internal" />
</context>
<context name="subst_paren_pattern" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Comment" context="#stay" String="\s+#.*$" />
<IncludeRules context="regex_pattern_internal_ip" />
<DetectChar attribute="Operator" context="subst_paren_replace" char="}" endRegion="Pattern" />
</context>
<context name="subst_paren_replace" attribute="String (interpolated)" lineEndContext="#stay">
<IncludeRules context="ipstring_internal" />
<DetectChar attribute="Operator" context="#stay" char="(" beginRegion="Replacement" />
<RegExpr attribute="Operator" context="#pop#pop#pop" String="\)[cegimosx]*" endRegion="Replacement" />
</context>
<context name="subst_bracket_pattern" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Comment" context="#stay" String="\s+#.*$" />
<IncludeRules context="regex_pattern_internal_ip" />
<DetectChar attribute="Operator" context="subst_bracket_replace" char="]" endRegion="Pattern" />
</context>
<context name="subst_bracket_replace" attribute="String (interpolated)" lineEndContext="#stay">
<IncludeRules context="ipstring_internal" />
<DetectChar attribute="Operator" context="#stay" char="[" beginRegion="Replacement" />
<RegExpr attribute="Operator" context="#pop#pop#pop" String="\][cegimosx]*" endRegion="Replacement" />
</context>
<context name="subst_slash_pattern" attribute="Pattern" lineEndContext="#stay" dynamic="true">
<RegExpr attribute="Pattern Internal Operator" context="#stay" String="\$(?=%1)" dynamic="true" />
<RegExpr attribute="Operator" context="subst_slash_replace" String="(%1)" dynamic="true" endRegion="Pattern" beginRegion="Replacement" />
<IncludeRules context="regex_pattern_internal_ip" />
</context>
<context name="subst_slash_replace" attribute="String (interpolated)" lineEndContext="#stay" dynamic="true">
<RegExpr attribute="Operator" context="#pop#pop#pop" String="%1[cegimosx]*" dynamic="true" endRegion="Replacement" />
<IncludeRules context="ipstring_internal" />
</context>
<context name="subst_sq_pattern" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Comment" context="#stay" String="\s+#.*$" />
<IncludeRules context="regex_pattern_internal" />
<DetectChar attribute="Operator" context="subst_sq_replace" char="'" endRegion="Pattern" beginRegion="Pattern" />
</context>
<context name="subst_sq_replace" attribute="String" lineEndContext="#stay">
<RegExpr attribute="Operator" context="#pop#pop#pop" String="'[cegimosx]*" endRegion="Replacement" />
</context>
<context name="tr" attribute="Pattern" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop" >
<RegExpr attribute="Pattern" context="#pop" String="\([^)]*\)\s*\(?:[^)]*\)" />
<RegExpr attribute="Pattern" context="#pop" String="\{[^}]*\}\s*\{[^}]*\}" />
<RegExpr attribute="Pattern" context="#pop" String="\[[^]]*\]\s*\[[^\]]*\]" />
<RegExpr attribute="Pattern" context="#pop" String="([^a-zA-Z0-9_\s[\]{}()]).*\1.*\1" minimal="true"/>
</context>
<!-- ====== PATTERNs ====== -->
<context name="find_pattern" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Comment" context="#stay" String="\s+#.*" /><!-- s # == comment, look for the delim on the next line -->
<DetectChar attribute="Operator" context="pattern_brace" char="{" beginRegion="Pattern" />
<DetectChar attribute="Operator" context="pattern_paren" char="(" beginRegion="Pattern" />
<DetectChar attribute="Operator" context="pattern_bracket" char="[" beginRegion="Pattern" />
<DetectChar attribute="Operator" context="pattern_sq" char="'" beginRegion="Pattern" />
<RegExpr attribute="Operator" context="pattern" String="([^\w\s])" beginRegion="Pattern" />
</context>
<context name="pattern_slash" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Pattern Internal Operator" context="#stay" String="\$(?=/)" />
<IncludeRules context="regex_pattern_internal_ip" />
<RegExpr attribute="Operator" context="#pop" String="/[cgimosx]*" endRegion="Pattern" />
</context>
<context name="pattern" attribute="Pattern" lineEndContext="#stay" dynamic="true">
<RegExpr attribute="Pattern Internal Operator" context="#stay" String="\$(?=%1)" dynamic="true" />
<RegExpr attribute="Operator" context="#pop#pop" String="%1[cgimosx]*" dynamic="true" endRegion="Pattern" />
<IncludeRules context="regex_pattern_internal_ip" />
<RegExpr attribute="Pattern Internal Operator" context="#stay" String="\$(?=\%1)" dynamic="true" />
</context>
<context name="pattern_brace" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Operator" context="#pop#pop" String="\}[cgimosx]*" endRegion="Pattern" />
<IncludeRules context="regex_pattern_internal_ip" />
</context>
<context name="pattern_bracket" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Operator" context="#pop#pop" String="\][cgimosx]*" endRegion="Pattern" />
<IncludeRules context="regex_pattern_internal_ip" />
</context>
<context name="pattern_paren" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Operator" context="#pop#pop" String="\)[cgimosx]*" endRegion="Pattern" />
<IncludeRules context="regex_pattern_internal_ip" />
</context>
<context name="pattern_sq" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Operator" context="#pop#pop" String="'[cgimosx]*" endRegion="Pattern" />
<IncludeRules context="regex_pattern_internal" />
</context>
<!-- rules internal stuff wrt regex patterns -->
<context name="regex_pattern_internal_rules_1" attribute="Pattern" lineEndContext="#stay">
<RegExpr attribute="Comment" context="#stay" String="#.*$" firstNonSpace="true" />
<RegExpr attribute="Pattern Character Class" context="#stay" String="\\[anDdSsWw]" />
<RegExpr attribute="Pattern Internal Operator" context="#stay" String="\\[ABbEGLlNUuQdQZz]" />
<RegExpr attribute="Special Variable" context="#stay" String="\\[\d]+" />
<RegExpr attribute="Pattern" context="#stay" String="\\." />
</context>
<context name="regex_pattern_internal_rules_2" attribute="Pattern" lineEndContext="#stay">
<Detect2Chars attribute="Pattern Internal Operator" context="pat_ext" char="(" char1="?" />
<DetectChar attribute="Pattern Internal Operator" context="pat_char_class" char="[" />
<RegExpr attribute="Pattern Internal Operator" context="#stay" String="[()?^*+|]" />
<RegExpr attribute="Pattern Internal Operator" context="#stay" String="\{[\d, ]+\}" />
<DetectChar attribute="Pattern Internal Operator" context="#stay" char="$" />
<RegExpr attribute="Comment" context="#stay" String="\s{3,}#.*$" />
</context>
<context name="regex_pattern_internal" attribute="Pattern" lineEndContext="#stay">
<IncludeRules context="regex_pattern_internal_rules_1" />
<IncludeRules context="regex_pattern_internal_rules_2" />
</context>
<context name="regex_pattern_internal_ip" attribute="Pattern" lineEndContext="#stay" >
<IncludeRules context="regex_pattern_internal_rules_1" />
<!-- NOTE the below means that the special variables $' $], $} and $> are not supported
within interpolated PATTERNs (apart from $(, $) and ${ and $| not supported by perl).
This is because perl considers
s{foo$} {bar} OK as well as s{foo$}} {bar}, and detecting that is a huge work overload
for something that is unlikely to happen. -->
<RegExpr attribute="Data Type" context="find_variable_unsafe" String="[$@][^]\s{}()|>']" lookAhead="true" />
<IncludeRules context="regex_pattern_internal_rules_2" />
</context>
<context name="pat_ext" attribute="Pattern Internal Operator" lineEndContext="#stay">
<RegExpr attribute="Comment" context="#pop" String="\#[^)]*" />
<RegExpr attribute="Pattern Internal Operator" context="#pop" String="[:=!><]+" />
<DetectChar attribute="Pattern Internal Operator" context="#pop" char=")" />
</context>
<context name="pat_char_class" attribute="Pattern Character Class" lineEndContext="#stay">
<DetectChar attribute="Pattern Internal Operator" context="#stay" char="^" />
<Detect2Chars attribute="Pattern Character Class" context="#stay" char="\" char1="\" />
<Detect2Chars attribute="Pattern Character Class" context="#stay" char="\" char1="]" />
<RegExpr attribute="Pattern Character Class" context="#stay" String="\[:\^?[a-z]+:\]" />
<DetectChar attribute="Pattern Internal Operator" context="#pop" char="]" />
</context>
<!-- ====== Variables ====== -->
<context name="find_variable" attribute="Data Type" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop" >
<RegExpr attribute="Special Variable" context="var_detect" String="\$[0-9]+" />
<RegExpr attribute="Special Variable" context="var_detect" String="[@\$](?:[\+\-_]\B|ARGV\b|INC\b)" />
<RegExpr attribute="Special Variable" context="var_detect" String="[%\$](?:INC\b|ENV\b|SIG\b)" />
<RegExpr attribute="Data Type" context="var_detect" String="\$\$[\$\w_]" />
<RegExpr attribute="Data Type" context="var_detect" String="\$[#_][\w_]" />
<RegExpr attribute="Data Type" context="var_detect" String="\$+::" />
<RegExpr attribute="Special Variable" context="var_detect" String="\$[^a-zA-Z0-9\s{][A-Z]?" />
<RegExpr attribute="Data Type" context="var_detect" String="[\$@%]\{[\w_]+\}" />
<AnyChar attribute="Data Type" context="var_detect" String="$@%" />
<RegExpr attribute="Data Type" context="var_detect" String="\*[a-zA-Z_]+" />
<RegExpr attribute="Special Variable" context="#stay" String="\*[^a-zA-Z0-9\s{][A-Z]?" />
<!-- this should be a rare case! -->
<AnyChar attribute="Operator" context="#pop" String="$@%*" />
</context>
<!-- This does not check fo a trailing slash, for usage in strings. -->
<context name="find_variable_unsafe" attribute="Data Type" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop" >
<RegExpr attribute="Special Variable" context="var_detect_unsafe" String="\$[0-9]+" />
<RegExpr attribute="Special Variable" context="var_detect_unsafe" String="[@\$](?:[\+\-_]\B|ARGV\b|INC\b)" />
<RegExpr attribute="Special Variable" context="var_detect_unsafe" String="[%\$](?:INC\b|ENV\b|SIG\b)" />
<RegExpr attribute="Data Type" context="var_detect_unsafe" String="\$\$[\$\w_]" />
<RegExpr attribute="Data Type" context="var_detect_unsafe" String="\$[#_][\w_]" />
<RegExpr attribute="Data Type" context="var_detect_unsafe" String="\$+::" />
<RegExpr attribute="Special Variable" context="#stay" String="\$[^a-zA-Z0-9\s{][A-Z]?" />
<RegExpr attribute="Data Type" context="var_detect_unsafe" String="[\$@%]\{[\w_]+\}" />
<RegExpr attribute="Data Type" context="var_detect_unsafe" String="[\$@%]" /><!-- AnyChar! -->
<RegExpr attribute="Data Type" context="var_detect_unsafe" String="\*\w+" />
<AnyChar attribute="Operator" context="#pop" String="$@%*" />
</context>
<context name="var_detect" attribute="Data Type" lineEndContext="#pop#pop" fallthrough="true" fallthroughContext="#pop#pop">
<IncludeRules context="var_detect_rules" />
<IncludeRules context="slash_safe_escape" />
</context>
<context name="var_detect_unsafe" attribute="Data Type" lineEndContext="#pop#pop" fallthrough="true" fallthroughContext="#pop#pop">
<IncludeRules context="var_detect_rules" />
</context>
<context name="var_detect_rules" attribute="Data Type" lineEndContext="#pop#pop" >
<RegExpr attribute="Data Type" context="#stay" String="[\w_]+" />
<Detect2Chars attribute="Normal Text" context="#stay" char=":" char1=":" />
<DetectChar attribute="Operator" context="#stay" char="'" />
<Detect2Chars attribute="Normal Text" context="#stay" char="-" char1=">" />
<!-- safe with operator / -->
<Detect2Chars attribute="Normal Text" context="#stay" char="+" char1="+" />
<Detect2Chars attribute="Normal Text" context="#stay" char="-" char1="-" />
</context>
<!-- ====== Word lists ====== -->
<context name="quote_word" attribute="Normal Text" lineEndContext="#stay" dynamic="true">
<DetectSpaces />
<DetectIdentifier />
<RegExpr attribute="Normal Text" context="#stay" String="\\%1" dynamic="true" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char="1" dynamic="true" endRegion="Wordlist" />
</context>
<context name="quote_word_paren" attribute="Normal Text" lineEndContext="#stay">
<DetectSpaces />
<DetectIdentifier />
<Detect2Chars attribute="Normal Text" context="#stay" char="\" char1=")" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char=")" endRegion="Wordlist" />
</context>
<context name="quote_word_brace" attribute="Normal Text" lineEndContext="#stay">
<DetectSpaces />
<DetectIdentifier />
<Detect2Chars attribute="Normal Text" context="#stay" char="\" char1="}" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char="}" endRegion="Wordlist" />
</context>
<context name="quote_word_bracket" attribute="Normal Text" lineEndContext="#stay">
<DetectSpaces />
<DetectIdentifier />
<Detect2Chars attribute="Normal Text" context="#stay" char="\" char1="]" />
<DetectChar attribute="Operator" context="#pop#pop#pop" char="]" endRegion="Wordlist" />
</context>
<!-- ====== Here Documents ====== -->
<context name="find_here_document" attribute="Normal Text" lineEndContext="#pop" >
<RegExpr attribute="Keyword" context="here_document" String="(\w+)\s*;?" />
<RegExpr attribute="Keyword" context="here_document" String="\s*"([^"]+)"\s*;?" />
<RegExpr attribute="Keyword" context="here_document" String="\s*`([^`]+)`\s*;?" />
<RegExpr attribute="Keyword" context="here_document_dumb" String="\s*'([^']+)'\s*;?" />
</context>
<context name="here_document" attribute="String (interpolated)" lineEndContext="#stay" dynamic="true">
<DetectSpaces />
<RegExpr attribute="Keyword" context="#pop#pop" String="^%1\b" column="0" dynamic="true" endRegion="HereDocument"/>
<RegExpr attribute="Keyword" context="here_document" String="\=\s*<<\s*["']?([A-Z0-9_\-]+)["']?" beginRegion="HEREDoc" />
<IncludeRules context="ipstring_internal" />
</context>
<context name="here_document_dumb" attribute="Normal Text" lineEndContext="#stay" dynamic="true">
<DetectSpaces />
<RegExpr attribute="Keyword" context="#pop#pop" String="%1" column="0" dynamic="true" endRegion="HereDocument"/>
<DetectIdentifier />
</context>
<!-- ====== Misc ====== -->
<context name="data_handle" attribute="Data" lineEndContext="#stay">
<RegExpr attribute="Pod" context="pod" String="\=(?:head[1-6]|over|back|item|for|begin|end|pod)\s+.*" column="0" beginRegion="POD"/>
<StringDetect attribute="Keyword" context="normal" String="__END__" firstNonSpace="true" />
</context>
<context name="end_handle" attribute="Nothing" lineEndContext="#stay">
<RegExpr attribute="Pod" context="pod" String="^\=(?:head[1-6]|over|back|item|for|begin|end|pod)\s*.*"/>
<StringDetect attribute="Keyword" context="data_handle" String="__DATA__" firstNonSpace="true" />
</context>
<context name="Backticked" attribute="String (interpolated)" lineEndContext="#stay">
<IncludeRules context="ipstring_internal"/>
<DetectChar attribute="Operator" context="#pop" char="`"/>
</context>
<context name="slash_safe_escape" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
<RegExpr attribute="Normal Text" context="#pop" String="\s*\}\s*/{1,2}" endRegion="Block"/>
<RegExpr attribute="Normal Text" context="#pop" String="\s*[)\]]?\s*/{1,2}" />
<keyword attribute="Keyword" context="#pop" String="keywords" /><!-- wonder why??? -->
</context>
<context name="package_qualified_blank" attribute="Normal Text" lineEndContext="#stay">
<RegExpr attribute="Normal Text" context="#pop" String="[\w_]+" />
</context>
<context name="sub_name_def" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
<RegExpr attribute="Function" context="#stay" String="\w+" />
<RegExpr attribute="Normal Text" context="find_variable" String="\$\S" lookAhead="true" />
<RegExpr attribute="Normal Text" context="sub_arg_definition" String="\s*\(" />
<Detect2Chars attribute="Normal Text" context="#stay" char=":" char1=":" />
</context>
<context name="sub_arg_definition" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop#pop">
<AnyChar attribute="Data Type" context="#stay" String="*$@%" />
<AnyChar attribute="Normal Text" context="#stay" String="&\[];" />
<DetectChar attribute="Normal Text" context="slash_safe_escape" char=")" />
</context>
<context name="pod" attribute="Pod" lineEndContext="#stay">
<DetectSpaces />
<DetectIdentifier />
<RegExpr attribute="Pod" context="#stay" String="\=(?:head[1-6]|over|back|item|for|begin|end|pod)\s*.*" column="0" beginRegion="POD" endRegion="POD"/>
<RegExpr attribute="Pod" context="#pop" String="\=cut.*$" column="0" endRegion="POD"/>
</context>
<context name="comment" attribute="Comment" lineEndContext="#pop">
<DetectSpaces />
<IncludeRules context="##Alerts" />
<DetectIdentifier />
</context>
</contexts>
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" />
<itemData name="Keyword" defStyleNum="dsKeyword" />
<itemData name="Pragma" defStyleNum="dsKeyword" />
<itemData name="Function" defStyleNum="dsFunction" />
<itemData name="Operator" defStyleNum="dsKeyword" color="#008000"/>
<itemData name="Data Type" defStyleNum="dsDataType" />
<itemData name="Special Variable" defStyleNum="dsDataType" color="#C00000" selColor="#C00000" bold="0" italic="0" />
<itemData name="Decimal" defStyleNum="dsDecVal" />
<itemData name="Octal" defStyleNum="dsBaseN" />
<itemData name="Hex" defStyleNum="dsBaseN" />
<itemData name="Bin" defStyleNum="dsBaseN" />
<itemData name="Float" defStyleNum="dsFloat" />
<itemData name="String" defStyleNum="dsString" color="#FF6C6C" selColor="#FF6C6C" bold="0" italic="0" />
<itemData name="String (interpolated)" defStyleNum="dsString" />
<itemData name="String Special Character" defStyleNum="dsChar" />
<itemData name="Pattern" defStyleNum="dsOthers" />
<itemData name="Pattern Internal Operator" defStyleNum="dsChar" />
<itemData name="Pattern Character Class" defStyleNum="dsBaseN" />
<itemData name="Data" defStyleNum="dsNormal" />
<itemData name="Comment" defStyleNum="dsComment" />
<itemData name="Pod" defStyleNum="dsComment" />
<itemData name="Nothing" defStyleNum="dsComment" />
</itemDatas>
</highlighting>
<general>
<comments>
<comment name="singleLine" start="#" />
</comments>
<keywords casesensitive="1" />
</general>
</language>
<!-- kate: space-indent on; indent-width 2; replace-tabs on; -->
|