chiark / gitweb /
auditor wip semiparse fixes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 Sep 2018 13:20:24 +0000 (14:20 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 Sep 2018 13:20:24 +0000 (14:20 +0100)
i18n-diff-auditor

index 654c323dd4ee308854ba403e3e229b8722204f3a..7398a8ec254ce296402c17ff581a302ed86b0a59 100755 (executable)
@@ -76,6 +76,7 @@ sub prep_perlop () {
        next if m{^list operators};
        s{ and unary.*}{};
        s{ etc\. }{ };
+       s{\?\:}{ ? : };
        foreach my $op (split /\s+/) {
            next unless length $op;
            next if $op =~ m{^\w+$};
@@ -106,17 +107,27 @@ sub semiparse ($) {
            s{^
                 (             .* \n    )
                 ( (?: (?! $d) .* \n )* )
-              }{ $1 } or die "missing end of here doc $d\n";
+                          $d     \n
+              }{ $1 }x or die "missing end of here doc $d\n";
            $o[$#o]{V} = $2;
-       } elsif (s{^ (["'])( (?:  [^\\] | \\ \1  )* )}{}x) {
+       } elsif (s{^ (["'])( (?: [^\\'"]
+                               | \\ [^"']
+                               | (?! \1 ) [^"]
+                              )*
+                       \1 )}{}x) {
            my ($q,$v) = ($1,$2);
            push @o, { T => 'string', Q => $q, V => $v };
-       } elsif (s{^$perlop_re}{}) {
+       } elsif (s{^$perlop_re|\;}{}) {
            push @o, { T => 'op', L => $& };
        } elsif (s/[[{(]//) {
            push @o, { T => 'bra', L => $& };
        } elsif (s/[]})]//) {
            push @o, { T => 'ket', L => $& };
+       } elsif (s/^( [\$\@\%] )( \{ )//x) {
+           push @o, { T => 'deref', L => $1 },
+                    { T => 'bra',   L => $2 };
+       } elsif (s/^ [\$\@\%] [^[^{] //x) {
+           push @o, { T => 'specvar', L => $& };
        } elsif (!length) {
            last;
        } else {
@@ -144,7 +155,7 @@ sub analyse_chunk () {
            # fudge this
            $before .= "\n$1\n";
            $after .= "\n$1\n";
-           analyse_chunk_core();
+           next;
        } else {
            die $@;
        }
@@ -164,7 +175,8 @@ for ($ifilehead = 0; l_ok $ifilehead; $ifilehead++) {
                    $ichunkend = $i;
                    eval { analyse_chunk(); 1; };
                    if (length $@) {
-                       print Dumper($ichunkstart, $ichunkend,
+                       print Dumper('REPORT',
+                                    $ichunkstart, $ichunkend,
                                     $before, $after,
                                     $@);
                    }