From fa0437c34c05cea5ea6c64debd353421481cb376 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 16 Mar 2003 23:47:32 +0000 Subject: [PATCH] Remove unused yyaccept variables (eliminates warnings from generated code). svn path=/trunk/yasm/; revision=868 --- tools/re2c/cleanup.pl | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tools/re2c/cleanup.pl b/tools/re2c/cleanup.pl index 7034a468..84f3da1e 100755 --- a/tools/re2c/cleanup.pl +++ b/tools/re2c/cleanup.pl @@ -1,10 +1,32 @@ #!/usr/bin/perl my @sourcelines = <>; my %usedlabel; +my %usedvar; +my $lastusedvarline = 0; +my $level = 0; +my $line = 1; for (@sourcelines) { - $usedlabel{"$1:"} = "$1:" if m/goto\s+(yy[0-9]*)\s*;/ + $usedlabel{"$1:"} = "$1:" if m/goto\s+(yy[0-9]*)\s*;/; + $level = $level + 1 if m/\{/; + $level = $level - 1 if m/\}/; + if ($level < $usedvar{$lastusedvarline}) { + $lastusedvarline = 0; + } + if (m/int\s+yyaccept/) { + $usedvar{$line} = $level; + $lastusedvarline = $line; + } elsif (m/yyaccept/) { + $usedvar{$lastusedvarline} = 1000; + } + $line = $line + 1; } +$line = 1; for (@sourcelines) { s/^(yy[0-9]*:)/$usedlabel{$1}/; - print; + if ($usedvar{$line} != 0 && $usedvar{$line} != 1000) { + print "\n"; + } else { + print; + } + $line = $line + 1; } -- 2.40.0