4 |
use Parse::RecDescent; |
use Parse::RecDescent; |
5 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
6 |
use File::Slurp; |
use File::Slurp; |
7 |
|
use Encode qw/decode/; |
8 |
|
|
9 |
=head1 NAME |
=head1 NAME |
10 |
|
|
17 |
|
|
18 |
It currently ignores C<include> PHP function. |
It currently ignores C<include> PHP function. |
19 |
|
|
20 |
|
=head1 CONFIG |
21 |
|
|
22 |
|
$A3C::PHP::debug = 0; |
23 |
|
$A3C::PHP::charset = 'iso-8859-2'; |
24 |
|
|
25 |
=head1 METHODS |
=head1 METHODS |
26 |
|
|
27 |
=cut |
=cut |
28 |
|
|
29 |
our $debug = 0; |
our $debug = 0; |
30 |
|
our $charset = 'iso-8859-2'; |
31 |
|
|
32 |
our $perl = ''; |
our $perl = ''; |
33 |
our $data; |
our $data; |
93 |
|
|
94 |
string: double_quoted | single_quoted |
string: double_quoted | single_quoted |
95 |
|
|
96 |
double_quoted: /".*?"/ |
double_quoted: /"(\\"|[^"])*?"/ |
97 |
{ |
{ |
98 |
$item[1] =~ s/\@/\\\@/g; |
$item[1] =~ s/\@/\\\@/g; |
99 |
$return = $item[1]; |
$return = $item[1]; |
100 |
} |
} |
101 |
|
|
102 |
single_quoted: /'.*?'/ |
single_quoted: /'(\\'|[^'])*?'/ |
103 |
|
|
104 |
element: scalar | bareword |
element: scalar | bareword |
105 |
|
|
133 |
$perl = ''; |
$perl = ''; |
134 |
if ( $debug ) { |
if ( $debug ) { |
135 |
$::RD_TRACE = 1; |
$::RD_TRACE = 1; |
136 |
warn "PHP: $php\n"; |
warn "PHP [$charset]: $php\n"; |
137 |
} |
} |
138 |
my $parser = Parse::RecDescent->new( $grammar ); |
my $parser = Parse::RecDescent->new( $grammar ); |
139 |
$parser->php_vars( $php ); |
$parser->php_vars( decode($charset,$php) ); |
140 |
warn "## GENERATED PERL:\n\n", $perl, "\n\n" if $debug; |
warn "## GENERATED PERL:\n\n", $perl, "\n\n" if $debug; |
141 |
my $data; |
my $data; |
142 |
eval $perl; |
eval $perl; |
163 |
|
|
164 |
=item * Parse::RecDescent |
=item * Parse::RecDescent |
165 |
|
|
166 |
|
=back |
167 |
|
|
168 |
=head1 AUTHORS |
=head1 AUTHORS |
169 |
|
|
170 |
=over 4 |
=over 4 |