K
kevin kitenik
Hi everybody,
i have a piece of html file, that countain special if-then-else statements :
like these ones:
<if condition="$vboptions['hometitle']"><a href="$vboptions[homeurl]">$vboptions[hometitle]</a> -</
if>
<if condition="$vboptions[privacyurl]"><a href="$vboptions[privacyurl]"><else><tr><td>test here
</if>
thos i statement can be imbricated :
if ... then ...
else
if .. then ...
fi
fi
the problem is i awant a wat to tansform these staments to :
((cond1)) ? (exec1)) : ((exec2)) styles.
how can i do this ???
i used the cpan without any succes !!
use Parse::RecDescent;
my @s=( q{<if condition="$vboptions['hometitle']"> <a href="$vboptions[homeurl]">$vboptions
[hometitle]</a> - </if>});
&pars;
sub pars {
my $parser = new Parse::RecDescent( q{
startrule: S
S: if ifC '">' then S else S fi {$return="(($item[2]) ? (\"$item[5]\") : ($item[7]))";}
| if ifC '">' then S fi {$return="(($item[2]) ? (\"$item[5]\") : (\"\"))";}
| html {$return=$item[1];}
if: '<if condition="'
fi: '</if>'
ifC: /[^"]+/
then: ''
else: '<else>' | '<else />'
html: /[\w\d_\$,\[\] ="\/\<\>-]+/ });
foreach my $s (@s){
print $s . ":\n" . $parser->startrule( $s ) . "\n"} }
i thank you in advance, for any syggestions, cause i have a headeack ;-)
i have a piece of html file, that countain special if-then-else statements :
like these ones:
<if condition="$vboptions['hometitle']"><a href="$vboptions[homeurl]">$vboptions[hometitle]</a> -</
if>
<if condition="$vboptions[privacyurl]"><a href="$vboptions[privacyurl]"><else><tr><td>test here
</if>
thos i statement can be imbricated :
if ... then ...
else
if .. then ...
fi
fi
the problem is i awant a wat to tansform these staments to :
((cond1)) ? (exec1)) : ((exec2)) styles.
how can i do this ???
i used the cpan without any succes !!
use Parse::RecDescent;
my @s=( q{<if condition="$vboptions['hometitle']"> <a href="$vboptions[homeurl]">$vboptions
[hometitle]</a> - </if>});
&pars;
sub pars {
my $parser = new Parse::RecDescent( q{
startrule: S
S: if ifC '">' then S else S fi {$return="(($item[2]) ? (\"$item[5]\") : ($item[7]))";}
| if ifC '">' then S fi {$return="(($item[2]) ? (\"$item[5]\") : (\"\"))";}
| html {$return=$item[1];}
if: '<if condition="'
fi: '</if>'
ifC: /[^"]+/
then: ''
else: '<else>' | '<else />'
html: /[\w\d_\$,\[\] ="\/\<\>-]+/ });
foreach my $s (@s){
print $s . ":\n" . $parser->startrule( $s ) . "\n"} }
i thank you in advance, for any syggestions, cause i have a headeack ;-)