-
Notifications
You must be signed in to change notification settings - Fork 5
/
rialacha.meta.pl
45 lines (45 loc) · 1.32 KB
/
rialacha.meta.pl
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
# This script is used for converting the hopefully-user-readable
# rialacha-xx.in into the somewhat complicated rialacha-xx.pl
# It only needs to be changed if the grammar of the .in file changes
# or new tags are added, etc.
# Copyright (C) 2003, 2004, 2005 Kevin P. Scannell <[email protected]>
#
# This is free software; see the file COPYING for copying conditions. There is
# NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
my $prev='';
# usually these two flags are the same, but not always with OK's at top
my $inokblock='false';
my $prevok='false';
while (<STDIN>) {
chomp;
s/\|<B><Z>[^+]+\+<\\\/Z>[^\/]+\/B>//g;
s/\(\?:<\[\\\/A-DF-Z\]\[\^>\]\*>\)\+/<[A-DF-Z][^>]*>/g;
if (/:OK *$/) {
# s/^/s\/<E[^>]*>(/;
# s/:OK *$/)<\\\/E>\/\$1\/g;/;
unless (/<E>/) {
s/^/<E>/;
s/:OK/<\\\/E>:OK/;
}
s/<E>/<E[^>]*>/;
s/^/s\/(/;
s/:OK *$/)\/strip_errors(\$1);\/eg;/;
unless ($inokblock eq 'true' or $prev eq '' or $prevok eq 'true') {
$prev =~ s/^/if (/;
$prev =~ s/;$/) {/;
$inokblock = 'true';
}
$prevok='true';
}
else {
s/^(.+[^?]):(.*)/s\/(?<![<>])($1)(?![<>])\/<E msg="$2">\$1<\\\/E>\/g;/;
$prev =~ s/$/\n}/ if ($inokblock eq 'true');
$inokblock='false';
$prevok='false';
}
print "$prev\n" if $prev;
$prev = $_;
}
$prev =~ s/$/\n}/ if ($inokblock eq 'true');
print "$prev\n";