blib/lib/Embperl/Syntax/ASP.pm untested

filter: Statementstmt 0.0% 0 / 79 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 115 CC 7 SCAR 30.5
CC
7
Cov
0%
AddTag
42.0
new
6.0
Init
2.0
CRAP 21.1
1  
2 ###################################################################################
3 #
4 # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de
5 # Embperl - Copyright (c) 2008-2015 Gerald Richter
6 # Embperl - Copyright (c) 2015-2023 actevy.io
7 #
8 # You may distribute under the terms of either the GNU General Public
9 # License or the Artistic License, as specified in the Perl README file.
10 #
11 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
12 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
13 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 #
15 ###################################################################################
16
17 package Embperl::Syntax::ASP ;
18  
19 use Embperl::Syntax qw{:types} ;
20 use Embperl::Syntax::HTML ;
21  
22 use strict ;
23 use vars qw{@ISA %Cmds %CmdsOutput %CmdsOutputLink} ;
24  
25 @ISA = qw(Embperl::Syntax::HTML) ;
26  
27  
28 ###################################################################################
29 #
30 # Methods
31 #
32 ###################################################################################
33  
34 # ---------------------------------------------------------------------------------
35 #
36 # Create new Syntax Object
37 #
38 # ---------------------------------------------------------------------------------
39  
40  
41 sub new
42  
43 {
44 my $class = shift ;
45  
46 my $self = Embperl::Syntax::HTML::new ($class) ;
47  
48 if (!$self -> {-aspInit})
49 {
50 $self -> {-aspInit} = 1 ;
51 Init ($self) ;
52 }
53  
54 return $self ;
55 }
56  
57  
58  
59 ###################################################################################
60 #
61 # Definitions for ASP HTML tags
62 #
63 ###################################################################################
64  
65 sub Init
66  
67 {
68 my ($self) = @_ ;
69  
70  
71 $self -> {-aspCmds} = $self -> CloneHash ({ %Cmds, %CmdsOutput }) ;
72 $self -> {-aspCmdsLink} = $self -> CloneHash ({ %Cmds, %CmdsOutputLink }, { 'unescape' => 2 }) ;
73  
74 $self -> AddToRoot ($self -> {-aspCmds}) ;
75  
76 $self -> AddToRoot ({
77 'ASP Syntax' => {
78 'text' => '<%?syntax',
79 'end' => '?%>',
80 'procinfo' => {
81 embperl => {
82 compiletimeperlcode => '$_[0] -> Syntax (Embperl::Syntax::GetSyntax(%#\'0%, $_[0] -> SyntaxName));',
83 parsetimeperlcode => '$_[0] -> Syntax (Embperl::Syntax::GetSyntax(\'%%\', $_[0] -> SyntaxName)) ;',
84 removenode => 3,
85 }
86 }
87 }
88 }) ;
89  
90  
91  
92 }
93  
94 # ---------------------------------------------------------------------------------
95 #
96 # Add new simple html tag (override to add asp commands inside html tags)
97 #
98 # ---------------------------------------------------------------------------------
99  
100  
101 sub AddTag
102  
103 {
104 my $self = shift ;
105  
106 my $tag = $self -> Embperl::Syntax::HTML::AddTag (@_) ;
107  
108 #### add the ASP cmd inside the new HTML Tag ####
109  
110 $tag -> {inside} ||= {} ;
111 my $inside = $tag -> {inside} ;
112  
113 while (my ($k, $v) = each (%{$self -> {-aspCmds}}))
114 {
115 $inside -> {$k} = $v ;
116 }
117  
118 if (!$self -> {-aspHTMLInit})
119 {
120 #### if not already done add the ASP cmds inside the HTML Attributes ####
121  
122 $self -> {-aspHTMLInit} = 1 ;
123  
124 my $unescape = 0 ;
125 foreach ('', 'Link')
126 {
127 my $attr = $self -> {"-htmlAssignAttr$_"} ;
128 my $blocks = $self -> {"-aspCmds$_"} ;
129 while (my ($k1, $v1) = each %$attr)
130 {
131 if (!($k1 =~ /^-/) && ref ($v1) eq 'HASH')
132 {
133 my $follow = $v1 -> {follow} ;
134 if (ref($follow) eq 'HASH')
135 {
136 while (my ($k2, $v2) = each %$follow)
137 {
138 if (ref($v2) eq 'HASH')
139 {
140 $v2 -> {inside} ||= {} ;
141 my $inside = $v2 -> {inside} ;
142  
143 while (my ($k, $v) = each (%$blocks))
144 {
145 $inside -> {$k} = $v ;
146 }
147 }
148 }
149 }
150 }
151 }
152 }
153  
154 my $quotes = $self -> {"-htmlQuotes"} ;
155 my $blocks = $self -> {"-aspCmds"} ;
156 while (my ($k2, $v2) = each %$quotes)
157 {
158 if (ref($v2) eq 'HASH')
159 {
160 $v2 -> {inside} ||= {} ;
161 my $inside = $v2 -> {inside} ;
162  
163 while (my ($k, $v) = each (%$blocks))
164 {
165 $inside -> {$k} = $v ;
166 }
167 }
168 }
169 }
170 return $tag ;
171 }
172  
173 ###################################################################################
174 #
175 # ASP Implementation
176 #
177 ###################################################################################
178  
179  
180  
181  
182 %Cmds = (
183 '-lsearch' => 1,
184 'ASP Code' => {
185 'text' => '<%',
186 'end' => '%>',
187 'procinfo' =>
188 {
189 embperl =>
190 {
191 perlcode => '%$c%%#0%',
192 removenode => 3,
193 mayjump => 1,
194 compilechilds => 0,
195 },
196 },
197 }
198 ) ;
199  
200 %CmdsOutput = (
201 'ASP Output' => {
202 'text' => '<%=',
203 'end' => '%>',
204 'procinfo' => {
205 embperl => {
206 perlcode =>
207 [
208 'if (!defined (_ep_rp(%$x%,scalar(%#~0:$col%)))) %#~-0:$row% { if ($col == 0) { _ep_dcp (%$t%,%^*htmltable%) ; last l%^*htmltable% ; } else { _ep_dcp (%$t%,%^*htmlrow%) ; last l%^*htmlrow% ; }}',
209 'if (!defined (_ep_rp(%$x%,scalar(%#~0:$col%)))) { _ep_dcp (%$t%,%^*htmlrow%) ; last l%^*htmlrow% ; }',
210 'if (!defined (_ep_rp(%$x%,scalar(%#~0:$row%)))) { _ep_dcp (%$t%,%^*htmltable%) ; last l%^*htmltable% ; }',
211 '_ep_rp(%$x%,scalar(%#0%));',
212 ],
213 removenode => 4,
214 mayjump => '%#~0:$col|$row|$cnt% %?*htmlrow% %?*htmltable%',
215 compilechilds => 0,
216 }
217 }
218 }
219 ) ;
220  
221 %CmdsOutputLink = (
222 'ASP Output Link' => {
223 'text' => '<%=',
224 'end' => '%>',
225 'nodename' => '<%=url',
226 'unescape' => 2,
227 'procinfo' => {
228 embperl => {
229 perlcode =>
230 [
231 'if (!defined (_ep_rpurl(%$x%,scalar(%#~0:$col%)))) %#~-0:$row% { if ($col == 0) { _ep_dcp (%$t%,%^*htmltable%) ; last l%^*htmltable% ; } else { _ep_dcp (%$t%,%^*htmlrow%) ; last l%^*htmlrow% ; }}',
232 'if (!defined (_ep_rpurl(%$x%,scalar(%#~0:$col%)))) { _ep_dcp (%$t%,%^*htmlrow%) ; last l%^*htmlrow% ; }',
233 'if (!defined (_ep_rpurl(%$x%,scalar(%#~0:$row%)))) { _ep_dcp (%$t%,%^*htmltable%) ; last l%^*htmltable% ; }',
234 '_ep_rpurl(%$x%,scalar(%#0%));',
235 ],
236 removenode => 4,
237 mayjump => '%#~0:$col|$row|$cnt% %?*htmlrow% %?*htmltable%',
238 compilechilds => 0,
239 }
240 }
241 }
242 ) ;
243  
244  
245 1;
246  
247 __END__