in reply to Appending strings
Another variation:
(Long lines: Beware linewrap.)c:\@Work\Perl\monks>perl -wMstrict -le "my $path = 'XX.YY.ZZ'; my ($ignore) = map qr{ (?: $_) (?! [[:alpha:]]) }xms, join q{ | }, qw(if while for) ; ;; my $s = '(ABC | (~dEf & hIJ)) & ~LMn if form while i'; ;; my $expected = '(XX.YY.ZZ.ABC | (~XX.YY.ZZ.dEf & XX.YY.ZZ.hIJ)) & ~XX +.YY.ZZ.LMn if XX.YY.ZZ.form while XX.YY.ZZ.i'; print qq{expected: '$expected'}; ;; $s =~ s{ (?<! [[:alpha:]]) (?= [[:alpha:]]) (?! $ignore) } {$path.}xmsg; print qq{ got: '$s'}; $s eq $expected or die 'FAILED'; print 'a-ok'; " expected: '(XX.YY.ZZ.ABC | (~XX.YY.ZZ.dEf & XX.YY.ZZ.hIJ)) & ~XX.YY.ZZ +.LMn if XX.YY.ZZ.form while XX.YY.ZZ.i' got: '(XX.YY.ZZ.ABC | (~XX.YY.ZZ.dEf & XX.YY.ZZ.hIJ)) & ~XX.YY.ZZ +.LMn if XX.YY.ZZ.form while XX.YY.ZZ.i' a-ok
Update: Just took another look at Re^2: Appending strings and realized solution above doesn't cover "1'b0" or "ABC_DEF". These could be included, but I'm sure that wouldn't be the end of it. Yeah, a real Verilog parser looks like the best bet.
Give a man a fish: <%-{-{-{-<
|
|---|