summaryrefslogtreecommitdiff
path: root/regress/fml4to8/show_rule_as_html.pl
blob: 1cb2af6e4a883b41d1aea7873dc91f655fc59280 (plain)
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
#!/usr/bin/env perl
#
# $FML: show_rule_as_html.pl,v 1.2 2004/12/09 11:35:12 fukachan Exp $
#

my $raw_mode = $ENV{ 'RAW_MODE' } ? 1 : 0;

print "<TABLE BORDER=4>\n" unless $raw_mode;
while (<>) {
    chomp;

    s/\s*$//;

    if (/^\.if\s*([A-Z]\S+)\s*.=\s*(.*)/) {
	$var_name  = $1;
	$var_value = $2;
	$var_value = /\!=/o ? "!= $var_value" : $var_value;

	$saved_var_name  = $var_name;
	$saved_var_value = $var_value;
    }
    elsif (/^\.if\s*([A-Z]\S+)/) {
	undef $condition;
	$var_name  = $1;
	$var_value = undef;

	$saved_var_name  = $var_name;
	$saved_var_value = $var_value;
    }

    if (/^\t\.if\s*([A-Z]\S+)\s*==\s*(.*)/) {
	$var_name  = "$saved_var_name && $1";
	$var_value = "$saved_var_value && $2";
    }
    elsif (/^\t(.*)/) {
	my $x = _P($1);
	if (defined $var_value) {
	    if ($raw_mode) {
		printf "%-40s  %s\n", "$var_name ($var_value)", $x;
	    }
	    else {
		printf "\t<TR>\n\t<TD>%s <TD>%s\n", 
		"$var_name ($var_value)", $x;
	    }
	}
	else {
	    if ($raw_mode) {
		printf "%-40s  %s\n", $var_name, $x;
	    }
	    else {
		printf "\t<TR>\n\t<TD>%s <TD>%s\n", $var_name, $x;
	    }
	}
    }
}

print "</TABLE>\n" unless $raw_mode;

exit 0;


sub _P
{
    my ($x) = @_;
    $x =~ s/\s*$//;
    $x =~ s/^\s*//;

    if ($raw_mode) { return $x;}

    #       .fml8_default           fml8 �Υǥե���Ȥ�Ʊ�������ˤ����
    #       .not_yet_implemented    �ޤ�����������Ƥʤ�
    #       .unavailable            �б������Τ��ʤ�������ͽ���ʤ�
    #       .ignore                 �����������㤦�Τǡ�̵��̣
    if ($x eq '.fml8_default') {
	return 'OK��fml8 �Υǥե���Ȥ�Ʊ��';
    }
    elsif ($x =~ /\.auto/) {
	$x =~ s/\.auto/fml8 �Ǥ��������ĥ��(��ư����)/;
	return $x;
    }
    elsif ($x =~ /\.convert/) {
	$x =~ s/\.convert/fml8 �η������Ѵ����ƻȤ�/;
	return $x;
    }
    elsif ($x =~ /\.use_fml4_value/) {
	$x =~ s/\.use_fml4_value/���Τޤ� fml4  ���ͤ�Ȥ�/;
	return $x;
    }
    elsif ($x =~ /\.use_fml8_value/) {
	$x =~ s/\.use_fml8_value/�б����� fml8 ���ͤ�Ȥ�/;
	return $x;
    }
    elsif ($x eq '.ignore') {
	return '�б������Τ��ʤ�';
    }
    elsif ($x eq '.unavailable') {
	return '����ͽ��ʤ�';
    }
    elsif ($x eq '.not_yet_configurable') {
	return '�ޤ������ѹ��Ǥ��ʤ�';
    }
    elsif ($x eq '.not_yet_implemented') {
	return '̤����';
    }
    else {
	if ($x =~ /^\s*\./) {
		print STDERR "INPUT{$x}\n";
	    use Carp;
	    croak($x);
	}
	else {
	    return $x;
	}
    }
}