line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package oEdtk::C7Tag;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.05';
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# A simple object that describes a Compuset tag.
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $TAG_OPEN = '<'; # une ouverture de balise compuset (open)
|
8
|
|
|
|
|
|
|
my $TAG_CLOSE = '>'; # une fermeture de balise compuset (close)
|
9
|
|
|
|
|
|
|
my $TAG_MARKER = '#'; # un marqueur de début de balise compuset
|
10
|
|
|
|
|
|
|
my $TAG_ASSIGN = '='; # un marqueur d'attribution de valeur compuset
|
11
|
|
|
|
|
|
|
my $TAG_COMMENT= ''; # un commentaire compuset (rem)
|
12
|
|
|
|
|
|
|
my $COMMENT = 'SK'; # un commentaire compuset (rem)
|
13
|
|
|
|
|
|
|
my $TAG_L_SET = ''; # attribution de variable : partie gauche
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new {
|
17
|
0
|
|
|
0
|
0
|
|
my ($class, $name, $val) = @_;
|
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
0
|
|
|
|
if (ref($val) ne '' && ref($val) ne 'HASH' && ref($val) ne 'oEdtk::C7Doc') {
|
|
|
|
0
|
|
|
|
|
20
|
0
|
|
|
|
|
|
die "ERROR: Unexpected value type, must be a scalar or a hashref\n";
|
21
|
|
|
|
|
|
|
}
|
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
if (length($name) > 8) {
|
24
|
0
|
|
|
|
|
|
warn "INFO : Tag name too long: $name\n";
|
25
|
|
|
|
|
|
|
}
|
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $self = {
|
28
|
|
|
|
|
|
|
name => $name,
|
29
|
|
|
|
|
|
|
value => $val
|
30
|
|
|
|
|
|
|
};
|
31
|
0
|
|
|
|
|
|
bless $self, $class;
|
32
|
0
|
|
|
|
|
|
return $self;
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub emit {
|
36
|
0
|
|
|
0
|
0
|
|
my ($self)= @_;
|
37
|
0
|
|
|
|
|
|
my $out = $TAG_OPEN;
|
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if (ref($self->{'value'}) ne 'HASH') {
|
40
|
0
|
0
|
|
|
|
|
if (defined $self->{'value'}) {
|
41
|
0
|
0
|
|
|
|
|
if (ref($self->{'value'}) eq '') {
|
42
|
|
|
|
|
|
|
# A 'simple' tag containing a textual value.
|
43
|
0
|
|
|
|
|
|
$self->{'value'} =~ s/\s+/ /g;
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ($self->{'name'}=~/^_include_$/){
|
47
|
0
|
|
|
|
|
|
$out .= 'include' . $TAG_CLOSE . $self->{'value'} . $TAG_OPEN . $COMMENT;
|
48
|
|
|
|
|
|
|
} else {
|
49
|
0
|
|
|
|
|
|
$out .= $TAG_MARKER . $self->{'name'} . '=' . $self->{'value'};
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} else {
|
53
|
0
|
|
|
|
|
|
$out .= $self->{'name'};
|
54
|
|
|
|
|
|
|
}
|
55
|
|
|
|
|
|
|
} else {
|
56
|
|
|
|
|
|
|
# A super tag containing other tags.
|
57
|
0
|
|
|
|
|
|
$out .= '#' . $self->{'name'} . "=";
|
58
|
0
|
|
|
|
|
|
while (my ($key, $val) = each %{$self->{'value'}}) {
|
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $tag = oEdtk::C7Tag->new($key, $val);
|
60
|
0
|
|
|
|
|
|
$out .= $tag->emit();
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
}
|
63
|
0
|
|
|
|
|
|
$out .= $TAG_CLOSE;
|
64
|
0
|
|
|
|
|
|
return $out;
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1;
|