line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
###
|
3
|
|
|
|
|
|
|
# CSS::SAC::Condition::Positional - SAC PositionalConditions
|
4
|
|
|
|
|
|
|
# Robin Berjon
|
5
|
|
|
|
|
|
|
# 24/02/2001
|
6
|
|
|
|
|
|
|
###
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package CSS::SAC::Condition::Positional;
|
9
|
2
|
|
|
2
|
|
15
|
use strict;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
110
|
|
10
|
2
|
|
|
2
|
|
12
|
use vars qw($VERSION);
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
285
|
|
11
|
|
|
|
|
|
|
$VERSION = $CSS::SAC::VERSION || '0.03';
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
12
|
use base qw(CSS::SAC::Condition);
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
391
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
17
|
|
|
|
|
|
|
# build the fields for an array based object
|
18
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
19
|
2
|
|
|
|
|
19
|
use Class::ArrayObjects extend => {
|
20
|
|
|
|
|
|
|
class => 'CSS::SAC::Condition',
|
21
|
|
|
|
|
|
|
with => [qw(
|
22
|
|
|
|
|
|
|
_position_
|
23
|
|
|
|
|
|
|
_same_type_
|
24
|
|
|
|
|
|
|
_same_node_type_
|
25
|
|
|
|
|
|
|
)],
|
26
|
2
|
|
|
2
|
|
13
|
};
|
|
2
|
|
|
|
|
3
|
|
27
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
### Constructor #######################################################
|
33
|
|
|
|
|
|
|
# #
|
34
|
|
|
|
|
|
|
# #
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
38
|
|
|
|
|
|
|
# CSS::SAC::Condition::Positional->new($type,$position,$node_type,$same_type)
|
39
|
|
|
|
|
|
|
# creates a new sac PositionalCondition object
|
40
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
41
|
|
|
|
|
|
|
sub new {
|
42
|
14
|
50
|
|
14
|
1
|
33
|
my $class = ref($_[0])?ref(shift):shift;
|
43
|
14
|
|
|
|
|
14
|
my $type = shift; # should be one of the content conditions
|
44
|
14
|
|
|
|
|
15
|
my $position = shift;
|
45
|
14
|
|
|
|
|
17
|
my $same_type = shift;
|
46
|
14
|
|
|
|
|
13
|
my $node_type = shift;
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
### IMPORTANT NOTE ###
|
50
|
|
|
|
|
|
|
#
|
51
|
|
|
|
|
|
|
# we will need to parse the new an+b expressions that can be found in
|
52
|
|
|
|
|
|
|
# positional conditions. In fact, old style simple numbers will be
|
53
|
|
|
|
|
|
|
# expressed that new way because they can be mapped to it.
|
54
|
|
|
|
|
|
|
#
|
55
|
|
|
|
|
|
|
# We'll need to provide for the corresponding accessors. Also, a
|
56
|
|
|
|
|
|
|
# ->position_matches($pos) method would be cool as it would allow
|
57
|
|
|
|
|
|
|
# client code to simply ask whether a position matches instead of
|
58
|
|
|
|
|
|
|
# calculating it itself.
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# create a condition
|
62
|
14
|
|
|
|
|
50
|
my $pcond = $class->SUPER::new($type);
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# add our fields
|
65
|
14
|
50
|
|
|
|
52
|
$pcond->[_position_] = $position if defined $position;
|
66
|
14
|
50
|
|
|
|
33
|
$pcond->[_same_type_] = $same_type if defined $same_type;
|
67
|
14
|
50
|
|
|
|
50
|
$pcond->[_same_node_type_] = $node_type if defined $node_type;
|
68
|
|
|
|
|
|
|
|
69
|
14
|
|
|
|
|
85
|
return $pcond;
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# #
|
75
|
|
|
|
|
|
|
# #
|
76
|
|
|
|
|
|
|
### Constructor #######################################################
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
### Accessors #########################################################
|
81
|
|
|
|
|
|
|
# #
|
82
|
|
|
|
|
|
|
# #
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# aliases
|
85
|
|
|
|
|
|
|
*CSS::SAC::Condition::Positional::getPosition = \&Position;
|
86
|
|
|
|
|
|
|
*CSS::SAC::Condition::Positional::getType = \&Type;
|
87
|
|
|
|
|
|
|
*CSS::SAC::Condition::Positional::getTypeNode = \&TypeNode;
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
91
|
|
|
|
|
|
|
# my $pos = $pcond->Position()
|
92
|
|
|
|
|
|
|
# $pcond->Position($pos)
|
93
|
|
|
|
|
|
|
# get/set the condition's position
|
94
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
95
|
|
|
|
|
|
|
sub Position {
|
96
|
14
|
50
|
|
14
|
1
|
127
|
(@_==2) ? $_[0]->[_position_] = $_[1] :
|
97
|
|
|
|
|
|
|
$_[0]->[_position_];
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
103
|
|
|
|
|
|
|
# my $bool = $pcond->Type()
|
104
|
|
|
|
|
|
|
# $pcond->Type($bool)
|
105
|
|
|
|
|
|
|
# get/set the condition's type constraint
|
106
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
107
|
|
|
|
|
|
|
sub Type {
|
108
|
14
|
50
|
|
14
|
1
|
123
|
(@_==2) ? $_[0]->[_same_type_] = $_[1] :
|
109
|
|
|
|
|
|
|
$_[0]->[_same_type_];
|
110
|
|
|
|
|
|
|
}
|
111
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
115
|
|
|
|
|
|
|
# my $bool = $pcond->TypeNode()
|
116
|
|
|
|
|
|
|
# $pcond->TypeNode($bool)
|
117
|
|
|
|
|
|
|
# get/set the condition's node type constraint
|
118
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
119
|
|
|
|
|
|
|
sub TypeNode {
|
120
|
0
|
0
|
|
0
|
1
|
|
(@_==2) ? $_[0]->[_same_node_type_] = $_[1] :
|
121
|
|
|
|
|
|
|
$_[0]->[_same_node_type_];
|
122
|
|
|
|
|
|
|
}
|
123
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# #
|
127
|
|
|
|
|
|
|
# #
|
128
|
|
|
|
|
|
|
### Accessors #########################################################
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1;
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=pod
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 NAME
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
CSS::SAC::Condition::Positional - SAC PositionalConditions
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
see CSS::SAC::Condition
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This is a subclass of CSS::SAC::Condition, look there for more
|
147
|
|
|
|
|
|
|
documentation. This class adds the following methods (the spec
|
148
|
|
|
|
|
|
|
equivalents are available as well, just prepend 'get'):
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 METHODS
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * CSS::SAC::Condition::Positional->new($type,$pos,$node_type,$same_type)
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * $cond->new($type,$pos,$node_type,$same_type)
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Creates a new positional condition.
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * $pcond->Position([$pos])
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
get/set the condition's position
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * $pcond->Type([$bool])
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
get/set the condition's type constraint
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * $pcond->TypeNode([$bool])
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
get/set the condition's node type constraint
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 AUTHOR
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Robin Berjon
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This module is licensed under the same terms as Perl itself.
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|