Changeset 21418 for perl5

Show
Ignore:
Timestamp:
07/20/08 20:38:43 (4 months ago)
Author:
fglock
Message:

[PCR] unicode fixes

Location:
perl5/Pugs-Compiler-Rule
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • perl5/Pugs-Compiler-Rule/Changes

    r21416 r21418  
     10.31  2008-07-21 
     2- unicode fixes 
     3 
    140.30  2008-07-20 
    25- fixed char class with spaces 
  • perl5/Pugs-Compiler-Rule/lib/Pugs/Compiler/Rule.pm

    r21416 r21418  
    55package Pugs::Compiler::Rule; 
    66 
    7 our $VERSION = '0.30'; 
     7our $VERSION = '0.31'; 
    88 
    99use base 'Pugs::Compiler::Regex'; 
  • perl5/Pugs-Compiler-Rule/lib/Pugs/Emitter/Rule/Perl5.pm

    r18705 r21418  
    296296sub special_char { 
    297297    my ($char, $data) = $_[0] =~ /^.(.)(.*)/; 
     298    $_[1] = '' unless defined $_[1]; 
    298299 
    299300    return  "$_[1] perl5( '\\N{" . join( "}\\N{", split( /\s*;\s*/, $data ) ) . "}' )\n" 
  • perl5/Pugs-Compiler-Rule/lib/Pugs/Emitter/Rule/Perl5/CharClass.pm

    r21416 r21418  
    22 
    33use strict; 
     4use charnames (); 
    45use Data::Dumper; 
    56 
     
    1213        word  xdigit 
    1314    ); 
     15} 
     16 
     17sub vianame { 
     18    my $c = shift; 
     19    my $s = charnames::vianame($c); 
     20    return $s if $s; 
     21    $s = charnames::vianame("LINE FEED (LF)")  
     22        if $c eq "LINE FEED" || $c eq "LF"; 
     23    return $s if $s; 
     24    $s = charnames::vianame("CARRIAGE RETURN (CR)")  
     25        if $c eq "CARRIAGE RETURN" || $c eq "CR"; 
     26    return $s if $s; 
     27    $s = charnames::vianame("FORM FEED (FF)")   
     28        if $c eq "FORM FEED" || $c eq "FF"; 
     29    return $s if $s; 
     30    $s = charnames::vianame("NEXT LINE (NEL)")  
     31        if $c eq "NEXT LINE" || $c eq "NEL"; 
     32    return $s if $s; 
    1433} 
    1534 
     
    3352        my ( $op, $cmd ) = /(.)(.*)/; 
    3453 
    35         $cmd =~ s/\s//g 
    36             unless $cmd =~ /\\c\[/; 
    37  
    38         #if ( $last_cmd eq '-' 
    39         #    && substr($cmd,0,1) eq '+' 
    40         #    ) 
    41         #{ 
    42         #    $out .= '|'; 
    43         #} 
    44         #$last_cmd = substr($cmd,0,1); 
    45  
     54        $cmd =~ s/ \\c\[ ([^];]+) \; ([^];]+) \] /  
     55                "\\x{" . sprintf("%02X", vianame($1)) . "}" 
     56              . "\\x{" . sprintf("%02X", vianame($2)) . "}" 
     57            /xgme; 
     58        $cmd =~ s/ \\c\[ ([^]]+) \] / "\\x[" . sprintf("%02X", vianame($1)) . ']' /xgme; 
     59        $cmd =~ s/ \\C\[ ([^]]+) \] / "\\X[" . sprintf("%02X", vianame($1)) . ']' /xgme; 
     60        $cmd =~ s/ \\o\[ ([^]]+) \] / "\\x[" . sprintf("%02X", oct($1)) . ']' /xgme; 
     61        $cmd =~ s/ \\O\[ ([^]]+) \] / "\\X[" . sprintf("%02X", oct($1)) . ']' /xgme; 
     62        $cmd =~ s/\s//g; 
     63         
    4664        $cmd =~ s/\.\./-/g;  # ranges 
    4765 
    48         # TODO - \o \O 
    49  
    50         if    ( $cmd =~ /^ \[ \\ c \[ (.*) \] \] /x ) { 
    51             #$cmd = "(?:\\N{" . join( "}|\\N{", split( /\s*;\s*/, $1 ) ) . "})"; 
    52             $cmd = "[\\N{" . join( "}\\N{", split( /\s*;\s*/, $1 ) ) . "}]"; 
    53         } 
    54         elsif ( $cmd =~ /^ \[ \\ C \[ (.*) \] \] /x ) { 
    55             #$cmd = "(?!\\N{" . join( "}|\\N{", split( /\s*;\s*/, $1 ) ) . "})\\X"; 
    56             $cmd = "[^\\N{" . join( "}\\N{", split( /\s*;\s*/, $1 ) ) . "}]"; 
    57         } 
    58  
    59  
    60         elsif ( $cmd =~ /^ \[ \\ x \[ (.*) \] \] /x ) { 
     66        if ( $cmd =~ /^ \[ \\ x \[ (.*) \] \] /x ) { 
    6167            $cmd = "(?:\\x{$1})"; 
    6268        } 
     
    6571            #$cmd = "[^\\x{$1}]"; 
    6672        } 
    67  
    6873 
    6974        elsif ( $cmd =~ /^ \s* \[ (.*) /x ) { 
     
    9398    $out = "(?:$out)\\X"; 
    9499 
    95     #print Dumper( @c ), ' == ', $out, "\n"; 
     100    #print Dumper( \@c ), ' == ', $out, "\n"; 
    96101 
    97102    return $out;