@@ -29,6 +29,13 @@ val ObjectiveCRegex = Regex(
29
29
)
30
30
var Perl5Regex = Regex (" \\ buse\\ s+(?:strict\\ b|v?5\\ .)" )
31
31
var Perl6Regex = Regex (" ^\\ s*(?:use\\ s+v6\\ b|\\ bmodule\\ b|\\ b(?:my\\ s+)?class\\ b)" )
32
+
33
+ var PLSQLRegexs = setOf (
34
+ Regex (" \\ \$ \\ \$ PLSQL_|XMLTYPE|sysdate|systimestamp|\\ .nextval|connect by|AUTHID (DEFINER|CURRENT_USER)" , RegexOption .IGNORE_CASE ),
35
+ Regex (" constructor\\ W+function" , RegexOption .IGNORE_CASE )
36
+ )
37
+ var NotSQLRegex = Regex (" begin|boolean|package|exception" , RegexOption .IGNORE_CASE )
38
+
32
39
var PythonRegex = Regex (" (^(import|from|class|def)\\ s)" , RegexOption .MULTILINE )
33
40
var RustRegex = Regex (" ^(use |fn |mod |pub |macro_rules|impl|#!?\\ [)" )
34
41
var RenderScriptRegex = Regex (" #include|#pragma\\ s+(rs|version)|__attribute__" )
@@ -73,6 +80,9 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
73
80
" bat" to { _ ->
74
81
CommonExtractor (" dosbatch" )
75
82
},
83
+ " bdy" to { _ ->
84
+ CommonExtractor (" plsql" )
85
+ },
76
86
" c" to { _ ->
77
87
CExtractor ()
78
88
},
@@ -115,6 +125,9 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
115
125
" cpy" to { _ ->
116
126
CommonExtractor (" cobol" )
117
127
},
128
+ " cql" to { _ ->
129
+ CommonExtractor (" sql" )
130
+ },
118
131
" cs" to { lines ->
119
132
val buf = toBuf(lines)
120
133
if (Regex (" ![\\ w\\ s]+methodsFor: " ).matches(buf)) CommonExtractor (" smalltalk" )
@@ -143,6 +156,17 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
143
156
else if (MakefileRegex .matches(buf)) CommonExtractor (" makefile" )
144
157
else null
145
158
},
159
+ " db2" to { _ ->
160
+ CommonExtractor (" sqlpl" )
161
+ },
162
+ " ddl" to { lines ->
163
+ val buf = toBuf(lines)
164
+ if (PLSQLRegexs .any { re -> re.containsMatchIn(buf)})
165
+ CommonExtractor (" plsql" ) // Oracle
166
+ else if (! NotSQLRegex .containsMatchIn(buf))
167
+ CommonExtractor (" sql" ) // Generic SQL
168
+ else null
169
+ },
146
170
" edn" to { _ ->
147
171
CommonExtractor (" clojure" )
148
172
},
@@ -189,6 +213,9 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
189
213
" factor" to { _ ->
190
214
CommonExtractor (" factor" )
191
215
},
216
+ " fnc" to { _ ->
217
+ CommonExtractor (" plsql" )
218
+ },
192
219
" for" to { lines ->
193
220
val buf = toBuf(lines)
194
221
if (ForthRegex .matches(buf)) CommonExtractor (" forth" )
@@ -349,6 +376,9 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
349
376
" mm" to { _ ->
350
377
ObjectiveCExtractor ()
351
378
},
379
+ " mysql" to { _ ->
380
+ CommonExtractor (" sql" )
381
+ },
352
382
" nb" to { _ ->
353
383
CommonExtractor (" wolframlanguage" )
354
384
},
@@ -364,6 +394,9 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
364
394
" pas" to { _ ->
365
395
CommonExtractor (" pascal" )
366
396
},
397
+ " pck" to { _ ->
398
+ CommonExtractor (" plsql" )
399
+ },
367
400
" pde" to { _ ->
368
401
CommonExtractor (" processing" )
369
402
},
@@ -386,13 +419,28 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
386
419
" phps" to { _ ->
387
420
PhpExtractor ()
388
421
},
422
+ " pkb" to { _ ->
423
+ CommonExtractor (" plsql" )
424
+ },
425
+ " pks" to { _ ->
426
+ CommonExtractor (" plsql" )
427
+ },
389
428
" pl" to { lines ->
390
429
val buf = toBuf(lines)
391
430
if (Regex (" ^[^#]*:-" ).matches(buf)) CommonExtractor (" prolog" )
392
431
else if (Perl5Regex .matches(buf)) CommonExtractor (" perl" )
393
432
else if (Perl6Regex .matches(buf)) CommonExtractor (" perl6" )
394
433
else null
395
434
},
435
+ " plb" to { _ ->
436
+ CommonExtractor (" plsql" )
437
+ },
438
+ " pls" to { _ ->
439
+ CommonExtractor (" plsql" )
440
+ },
441
+ " plsql" to { _ ->
442
+ CommonExtractor (" plsql" )
443
+ },
396
444
" pm" to { lines ->
397
445
val buf = toBuf(lines)
398
446
if (Perl5Regex .matches(buf)) CommonExtractor (" perl" )
@@ -406,6 +454,9 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
406
454
" pp" to { _ ->
407
455
CommonExtractor (" puppet" )
408
456
},
457
+ " prc" to { _ ->
458
+ CommonExtractor (" plsql" )
459
+ },
409
460
" pro" to { lines ->
410
461
val buf = toBuf(lines)
411
462
if (Regex (" ^[^\\ [#]+:-" ).matches(buf)) CommonExtractor (" prolog" )
@@ -497,8 +548,21 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
497
548
" sh" to { _ ->
498
549
CommonExtractor (" shell" )
499
550
},
500
- " sql" to { _ ->
501
- CommonExtractor (" sql" )
551
+ " spc" to { _ ->
552
+ CommonExtractor (" plsql" )
553
+ },
554
+ " sql" to { lines ->
555
+ val buf = toBuf(lines)
556
+ if (Regex (" ^\\\\ i\\ b|AS \\ $\\ $|LANGUAGE '?plpgsql'?" , RegexOption .IGNORE_CASE ).containsMatchIn(buf) ||
557
+ Regex (" SECURITY (DEFINER|INVOKER)" , RegexOption .IGNORE_CASE ).containsMatchIn(buf) ||
558
+ Regex (" BEGIN( WORK| TRANSACTION)?;" , RegexOption .IGNORE_CASE ).containsMatchIn(buf))
559
+ CommonExtractor (" plpgsql" ) // Postgres
560
+ else if (Regex (" (alter module)|(language sql)|(begin( NOT)+ atomic)" , RegexOption .IGNORE_CASE ).containsMatchIn(buf) ||
561
+ Regex (" signal SQLSTATE '[0-9]+'" , RegexOption .IGNORE_CASE ).containsMatchIn(buf))
562
+ CommonExtractor (" sqlpl" ) // IBM db2
563
+ else if (PLSQLRegexs .any { re -> re.containsMatchIn(buf)})
564
+ CommonExtractor (" plsql" ) // Oracle
565
+ else CommonExtractor (" sql" ) // Generic SQL
502
566
},
503
567
" ss" to { _ ->
504
568
CommonExtractor (" scheme" )
@@ -509,12 +573,24 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
509
573
" swift" to { _ ->
510
574
SwiftExtractor ()
511
575
},
576
+ " tab" to { _ ->
577
+ CommonExtractor (" sql" )
578
+ },
512
579
" tcl" to { _ ->
513
580
CommonExtractor (" tcl" )
514
581
},
515
582
" tex" to { _ ->
516
583
CommonExtractor (" tex" )
517
584
},
585
+ " tpb" to { _ ->
586
+ CommonExtractor (" plsql" )
587
+ },
588
+ " tps" to { _ ->
589
+ CommonExtractor (" plsql" )
590
+ },
591
+ " trg" to { _ ->
592
+ CommonExtractor (" plsql" )
593
+ },
518
594
" ts" to { lines ->
519
595
if (Regex (" <TS\\ b" ).matches(toBuf(lines))) CommonExtractor (" xml" )
520
596
else CommonExtractor (" typescript" )
@@ -527,6 +603,9 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
527
603
CommonExtractor (" xml" )
528
604
else null
529
605
},
606
+ " udf" to { _ ->
607
+ CommonExtractor (" sql" )
608
+ },
530
609
" v" to { _ ->
531
610
CommonExtractor (" verilog" )
532
611
},
@@ -539,9 +618,15 @@ val Heuristics = mapOf<String, (List<String>) -> ExtractorInterface?>(
539
618
" vim" to { _ ->
540
619
CommonExtractor (" viml" )
541
620
},
621
+ " viw" to { _ ->
622
+ CommonExtractor (" sql" )
623
+ },
542
624
" vue" to { _ ->
543
625
CommonExtractor (" vue" )
544
626
},
627
+ " vw" to { _ ->
628
+ CommonExtractor (" plsql" )
629
+ },
545
630
" xtend" to { _ ->
546
631
CommonExtractor (" xtend" )
547
632
}
0 commit comments