/[A3C]/lib/A3C/PHP.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/A3C/PHP.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 136 by dpavlin, Fri May 30 20:53:14 2008 UTC revision 152 by dpavlin, Tue Jun 3 19:40:12 2008 UTC
# Line 4  use strict; Line 4  use strict;
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    
# Line 16  parser based on L<PHP::Include::Vars> Line 17  parser based on L<PHP::Include::Vars>
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;
# Line 86  number:                /-?[0-9.]+/ Line 93  number:                /-?[0-9.]+/
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    
# Line 126  sub parse { Line 133  sub parse {
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;
# Line 156  sub parse_file { Line 163  sub parse_file {
163    
164  =item * Parse::RecDescent  =item * Parse::RecDescent
165    
166    =back
167    
168  =head1 AUTHORS  =head1 AUTHORS
169    
170  =over 4  =over 4

Legend:
Removed from v.136  
changed lines
  Added in v.152

  ViewVC Help
Powered by ViewVC 1.1.26