| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MarpaX::Languages::SVG::Parser::Actions; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
5
|
1
|
|
|
1
|
|
21
|
use warnings; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
33
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings qw(FATAL utf8); # Fatalize encoding glitches. |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
381
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my($item_count); |
|
9
|
|
|
|
|
|
|
my($param_count); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $logger; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.09'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub boolean |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
0
|
|
|
0
|
1
|
|
my($hashref, $t1) = @_; |
|
20
|
0
|
|
|
|
|
|
$t1 = lc $t1; |
|
21
|
0
|
0
|
|
|
|
|
$t1 = $t1 eq 'zero' ? 0 : 1; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
0
|
|
|
|
|
|
count => ++$item_count, |
|
26
|
|
|
|
|
|
|
name => ++$param_count, |
|
27
|
|
|
|
|
|
|
type => 'boolean', |
|
28
|
|
|
|
|
|
|
value => $t1, |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} # End of boolean. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub command |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
0
|
|
|
0
|
1
|
|
my($hashref, $t1, @t2) = @_; |
|
38
|
0
|
|
|
|
|
|
$param_count = 0; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
0
|
|
|
|
|
|
count => ++$item_count, |
|
43
|
|
|
|
|
|
|
name => $t1, |
|
44
|
|
|
|
|
|
|
type => 'command', |
|
45
|
|
|
|
|
|
|
value => [@t2], |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} # End of command. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub float |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
0
|
|
|
0
|
1
|
|
my($hashref, $t1) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
0
|
|
|
|
|
|
count => ++$item_count, |
|
59
|
|
|
|
|
|
|
name => ++$param_count, |
|
60
|
|
|
|
|
|
|
type => 'float', |
|
61
|
|
|
|
|
|
|
value => $t1, |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} # End of float. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub init |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
0
|
|
|
0
|
1
|
|
$item_count = 0; |
|
71
|
0
|
|
|
|
|
|
$param_count = 0; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} # End of init. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub integer |
|
78
|
|
|
|
|
|
|
{ |
|
79
|
0
|
|
|
0
|
1
|
|
my($hashref, $t1) = @_; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
return |
|
82
|
|
|
|
|
|
|
{ |
|
83
|
0
|
|
|
|
|
|
count => ++$item_count, |
|
84
|
|
|
|
|
|
|
name => ++$param_count, |
|
85
|
|
|
|
|
|
|
type => 'integer', |
|
86
|
|
|
|
|
|
|
value => $t1, |
|
87
|
|
|
|
|
|
|
}; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} # End of integer. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# -------------------------------------------------- |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub log |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
0
|
|
|
0
|
1
|
|
my($level, $s) = @_; |
|
96
|
0
|
0
|
|
|
|
|
$level = 'notice' if (! defined $level); |
|
97
|
0
|
0
|
|
|
|
|
$s = '' if (! defined $s); |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
$logger -> $level($s) if ($logger); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} # End of log. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub string |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
0
|
|
|
0
|
1
|
|
my($hashref, $t1) = @_; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
return |
|
110
|
|
|
|
|
|
|
{ |
|
111
|
0
|
|
|
|
|
|
count => ++$item_count, |
|
112
|
|
|
|
|
|
|
name => ++$param_count, |
|
113
|
|
|
|
|
|
|
type => 'string', |
|
114
|
|
|
|
|
|
|
value => $t1, |
|
115
|
|
|
|
|
|
|
}; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} # End of string. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# ------------------------------------------------ |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=pod |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 NAME |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
C - A nested SVG parser, using XML::SAX and Marpa::R2 |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 Synopsis |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
See L. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 Description |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Basically just utility routines for L. Only used indirectly by L. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Specifially, calls to functions are triggered by items in the input stream matching elements of the current |
|
138
|
|
|
|
|
|
|
grammar (and Marpa does the calling). |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Each action function returns a hashref, which Marpa gathers. The calling code |
|
141
|
|
|
|
|
|
|
L decodes the result and puts the hashrefs into a stack, described in |
|
142
|
|
|
|
|
|
|
the L. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 Installation |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
See L. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 Constructor and Initialization |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This class has no constructor. L fabricates an instance, but won't let us get access to it. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
So, we use a global variable, C<$logger>, initialized in L, |
|
153
|
|
|
|
|
|
|
in case we need logging. Details: |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over 4 |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item o logger => aLog::HandlerObject |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
By default, an object of type L is created which prints to STDOUT, |
|
160
|
|
|
|
|
|
|
but given the default, nothing is actually printed unless the C attribute of this object is changed |
|
161
|
|
|
|
|
|
|
in L. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Default: anObjectOfTypeLogHandler. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=back |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Also, each new parse is preceeded by a call to the L function, to reset some counters global to this file. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 Methods |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
None. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 Functions |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 boolean($t1) |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Returns a hashref identifying the boolean $t1. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 command($t1, @t2) |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Returns a hashref identifying the command $t1 and its parameters in @t2. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 float($t1) |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Returns a hashref identifying the float $t1. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 init() |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Resets some counters global to the file. This must be called at the start of each new parse. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 integer($t1) |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Returns a hashref identifying the integer $t1. |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 log($level, $s) |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Calls $logger -> log($level => $s) if ($logger). |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 string($t1) |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Returns a hashref identifying the string $t1. |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 FAQ |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
See L. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 Author |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
L was written by Ron Savage Iron@savage.net.auE> in 2013. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Home page: L. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 Copyright |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Australian copyright (c) 2013, Ron Savage. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
All Programs of mine are 'OSI Certified Open Source Software'; |
|
218
|
|
|
|
|
|
|
you can redistribute them and/or modify them under the terms of |
|
219
|
|
|
|
|
|
|
The Artistic License 2.0, a copy of which is available at: |
|
220
|
|
|
|
|
|
|
http://www.opensource.org/licenses/index.html |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=cut |