From 55df3f9b582e79b4b793a4ef672f731057f275d4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 30 Sep 2018 14:20:24 +0100 Subject: [PATCH] auditor wip semiparse fixes --- i18n-diff-auditor | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/i18n-diff-auditor b/i18n-diff-auditor index 654c323..7398a8e 100755 --- a/i18n-diff-auditor +++ b/i18n-diff-auditor @@ -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, $@); } -- 2.30.2