mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-19 10:29:30 +01:00
Improvements to C-to-English
This commit is contained in:
parent
d51d2367a1
commit
3f6f3b6a36
18
modules/c2english/CGrammar.pm
Normal file → Executable file
18
modules/c2english/CGrammar.pm
Normal file → Executable file
@ -171,6 +171,12 @@ function_definition:
|
|||||||
$return_type = "which shouldn't return to its caller yet does mysteriously return $return_type";
|
$return_type = "which shouldn't return to its caller yet does mysteriously return $return_type";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ref $name eq 'ARRAY') {
|
||||||
|
my @a = @$name;
|
||||||
|
$name = shift @a;
|
||||||
|
$parameter_list = join(' ', @a) . " $parameter_list";
|
||||||
|
}
|
||||||
|
|
||||||
$return = "\nLet $name be a $parameter_list $return_type.\n";
|
$return = "\nLet $name be a $parameter_list $return_type.\n";
|
||||||
|
|
||||||
@ -625,7 +631,7 @@ logical_OR_AND_expression:
|
|||||||
my $expression = join('', @{$item[1]});
|
my $expression = join('', @{$item[1]});
|
||||||
if($arg{context} =~ /initializer expression$/
|
if($arg{context} =~ /initializer expression$/
|
||||||
and $expression =~ / /
|
and $expression =~ / /
|
||||||
and $expression !~ /^the .*? number \S+$/i
|
and $expression !~ /^the .*? constant \S+$/i
|
||||||
and $expression !~ /the size of/i
|
and $expression !~ /the size of/i
|
||||||
and $expression !~ /the offset/i
|
and $expression !~ /the offset/i
|
||||||
and $expression !~ /the address of/i
|
and $expression !~ /the address of/i
|
||||||
@ -1111,7 +1117,7 @@ postfix_productions:
|
|||||||
} elsif ($expression =~ /^-\s*\d+$/) {
|
} elsif ($expression =~ /^-\s*\d+$/) {
|
||||||
$expression *= -1;
|
$expression *= -1;
|
||||||
my $plural = $expression == 1 ? '' : 's';
|
my $plural = $expression == 1 ? '' : 's';
|
||||||
$return = "the location $expression element$plural backwards from where ^L$arg{primary_expression} points^L";
|
$return = "the element $expression element$plural backwards from where ^L$arg{primary_expression} points^L";
|
||||||
} else {
|
} else {
|
||||||
$return = "the element at location ^L$expression of^L";
|
$return = "the element at location ^L$expression of^L";
|
||||||
$return .= " $arg{primary_expression}" if $arg{primary_expression};
|
$return .= " $arg{primary_expression}" if $arg{primary_expression};
|
||||||
@ -1343,7 +1349,7 @@ declarator:
|
|||||||
if (@direct_declarator == 1) {
|
if (@direct_declarator == 1) {
|
||||||
$return = $direct_declarator[0];
|
$return = $direct_declarator[0];
|
||||||
} else {
|
} else {
|
||||||
$return = $item{'direct_declarator(s)'};
|
$return = $item{'direct_declarator(s)'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| pointer direct_declarator(s)
|
| pointer direct_declarator(s)
|
||||||
@ -1855,7 +1861,7 @@ constant:
|
|||||||
/-?[0-9]*\.[0-9]*[lf]{0,2}/i
|
/-?[0-9]*\.[0-9]*[lf]{0,2}/i
|
||||||
{
|
{
|
||||||
if ($item[1] =~ s/f$//i) {
|
if ($item[1] =~ s/f$//i) {
|
||||||
$return = "the floating point number $item[1]";
|
$return = "the floating point constant $item[1]";
|
||||||
} elsif ($item[1] =~ s/l$//i) {
|
} elsif ($item[1] =~ s/l$//i) {
|
||||||
$return = "long double $item[1]";
|
$return = "long double $item[1]";
|
||||||
} else {
|
} else {
|
||||||
@ -1867,13 +1873,13 @@ constant:
|
|||||||
{
|
{
|
||||||
$return .= 'unsigned ' if $item[1] =~ s/[Uu]//;
|
$return .= 'unsigned ' if $item[1] =~ s/[Uu]//;
|
||||||
$return .= 'long ' while $item[1] =~ s/[Ll]//;
|
$return .= 'long ' while $item[1] =~ s/[Ll]//;
|
||||||
$return = "the $return" . "hexadecimal number $item[1]";
|
$return = "the $return" . "hexadecimal constant $item[1]";
|
||||||
}
|
}
|
||||||
| /0\d+[lu]{0,3}/i
|
| /0\d+[lu]{0,3}/i
|
||||||
{
|
{
|
||||||
$return .= 'unsigned ' if $item[1] =~ s/[Uu]//;
|
$return .= 'unsigned ' if $item[1] =~ s/[Uu]//;
|
||||||
$return .= 'long ' while $item[1] =~ s/[Ll]//;
|
$return .= 'long ' while $item[1] =~ s/[Ll]//;
|
||||||
$return = "the $return" . "octal number $item[1]";
|
$return = "the $return" . "octal constant $item[1]";
|
||||||
}
|
}
|
||||||
| /-?[0-9]+[lu]{0,3}/i # integer constant
|
| /-?[0-9]+[lu]{0,3}/i # integer constant
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ foreach my $arg (@ARGV) {
|
|||||||
$output =~ s/the function a generic-selection/the function resulting from a generic-selection/g;
|
$output =~ s/the function a generic-selection/the function resulting from a generic-selection/g;
|
||||||
$output =~ s/\.\s+Then exit switch block/ and then exit switch block/g;
|
$output =~ s/\.\s+Then exit switch block/ and then exit switch block/g;
|
||||||
$output =~ s/,\././g;
|
$output =~ s/,\././g;
|
||||||
$output =~ s/const const/const/g;
|
while($output =~ s/const const/const/g){};
|
||||||
|
|
||||||
foreach my $quote (@quotes) {
|
foreach my $quote (@quotes) {
|
||||||
next unless $quote;
|
next unless $quote;
|
||||||
|
Loading…
Reference in New Issue
Block a user