CGrammar: Move output beautification to c2eng.pl; white-out string literals before beautifying

This commit is contained in:
Pragmatic Software 2014-06-28 14:41:50 +00:00
parent 5730d56d54
commit 086d5059b1
3 changed files with 17 additions and 7 deletions

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 683,
BUILD_REVISION => 684,
BUILD_DATE => "2014-06-28",
};

View File

@ -404,11 +404,6 @@ if(not $output) {
$output = "Does not compute; I only understand valid C89 code.\n";
}
# beautification
$output =~ s/the value the expression/the value of the expression/g;
$output =~ s/the value the member/the value of the member/g;
$output =~ s/the value the/the/g;
print "$output\n";
sub execute {

View File

@ -69,7 +69,22 @@ foreach my $arg (@ARGV) {
if(length $text) {
print "Bad parse at: $text";
} else {
print join('', flatten($result));
my $output = join('', flatten($result));
# beautification
my @quotes;
$output =~ s/(?:\"((?:\\\"|(?!\").)*)\")/push @quotes, $1; '"' . ('-' x length $1) . '"'/ge;
$output =~ s/the value the expression/the value of the expression/g;
$output =~ s/the value the member/the value of the member/g;
$output =~ s/the value the/the/g;
$output =~ s/of evaluate/of/g;
foreach my $quote (@quotes) {
$output =~ s/"-*"/"$quote"/;
}
print $output;
}
}