File indexing completed on 2024-05-12 04:02:13

0001 #!/usr/bin/env perl
0002 # SPDX-FileCopyrightText: 2020 Jonathan Poelen <jonathan.poelen@gmail.com>
0003 # SPDX-License-Identifier: MIT
0004 
0005 my $file = "";
0006 
0007 open(my $input, '<:encoding(UTF-8)', $ARGV[0])
0008   or die "Could not open file '$ARGV[0]': $!";
0009 
0010 open(my $output, '>:encoding(UTF-8)', $ARGV[1])
0011   or die "Could not open file '$ARGV[1]': $!";
0012 
0013 while (<$input>)
0014 {
0015   $file .= $_;
0016 }
0017 
0018 $warning = "\n\n<!-- ***** THIS FILE WAS GENERATED BY A SCRIPT - DO NOT EDIT ***** -->\n";
0019 $first_context = "      <context attribute=\"Normal Text\" lineEndContext=\"#stay\" name=\"Normal\">
0020         <RegExpr attribute=\"Comment\" context=\"LineComment\" String=\"--(?:!|(?:-(?=[^-]|\$)))\"/>
0021         <RegExpr attribute=\"Region\" context=\"#stay\" String=\"--\\s*\@\\{\\s*\$\" beginRegion=\"MemberGroup\" />
0022         <RegExpr attribute=\"Region\" context=\"#stay\" String=\"--\\s*\@\\}\\s*\$\"   endRegion=\"MemberGroup\" />
0023       </context>";
0024 
0025 $file =~ s/\n\s*<context [^\n]*?(?:name="ML_|name="BlockComment").*?<\/context>//gs;
0026 $file =~ s/\n\s*<context [^\n]*?name="Normal".*?<\/context>/\n$first_context/s;
0027 $file =~ s/\n[^\n]*?(?: ml_word|LineContinue)[^\n]+//gs;
0028 $file =~ s/\/\/\//---/gs;
0029 $file =~ s/\/\/!/--!/gs;
0030 
0031 $language = $file =~ s/.*?(<language[^>]+?>).*/$1/sr;
0032 $language =~ s/ name="[^"]+/ name="DoxygenLua/s;
0033 $language =~ s/ extensions="[^"]+/ extensions="/s;
0034 $language =~ s/ mimetype="[^"]+/ mimetype="/s;
0035 $language =~ s/ priority="[^"]+"//s;
0036 $version = $language =~ s/.*? version="([^"]+).*/$1/sr;
0037 $version = $version+2;
0038 $language =~ s/ version="[^"]+/ version="$version/s;
0039 $file =~ s/<language[^>]+?>/$warning\n$language/s;
0040 
0041 print $output $file;
0042 print $output $warning;