mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
CGrammar: Fix declarations without identifier
This commit is contained in:
parent
9c5b307bef
commit
4583d85b50
@ -13,7 +13,7 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 704,
|
BUILD_REVISION => 705,
|
||||||
BUILD_DATE => "2014-07-04",
|
BUILD_DATE => "2014-07-04",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ close $fh;
|
|||||||
$output = `./c2eng.pl code2eng.c` if not defined $output;
|
$output = `./c2eng.pl code2eng.c` if not defined $output;
|
||||||
|
|
||||||
if(not $has_function and not $has_main) {
|
if(not $has_function and not $has_main) {
|
||||||
$output =~ s/Let .main. be a function taking no arguments and returning int.\s*When called, the function will.\s*(return 0.)?//i;
|
$output =~ s/Let .main. be a function taking no arguments and returning int.\s*When called, the function will.\s*(do nothing.)?//i;
|
||||||
$output =~ s/\s*Return 0.\s*End of function .main..\s*//;
|
$output =~ s/\s*Return 0.\s*End of function .main..\s*//;
|
||||||
$output =~ s/\s*Finally, return 0.$//;
|
$output =~ s/\s*Finally, return 0.$//;
|
||||||
$output =~ s/\s*and then return 0.$/./;
|
$output =~ s/\s*and then return 0.$/./;
|
||||||
@ -397,7 +397,7 @@ if(not $has_function and not $has_main) {
|
|||||||
$output =~ s/^\s*(.)/\U$1/;
|
$output =~ s/^\s*(.)/\U$1/;
|
||||||
$output =~ s/\.\s+(\S)/. \U$1/g;
|
$output =~ s/\.\s+(\S)/. \U$1/g;
|
||||||
} elsif($has_function and not $has_main) {
|
} elsif($has_function and not $has_main) {
|
||||||
$output =~ s/\s*Let `main` be a function taking no arguments and returning int.\s*When called, the function will return 0.//;
|
$output =~ s/\s*Let `main` be a function taking no arguments and returning int.\s*When called, the function will do nothing.//;
|
||||||
$output =~ s/\s*Finally, return 0.$//;
|
$output =~ s/\s*Finally, return 0.$//;
|
||||||
$output =~ s/\s*and then return 0.$/./;
|
$output =~ s/\s*and then return 0.$/./;
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,9 @@ undefinition:
|
|||||||
|
|
||||||
inclusion:
|
inclusion:
|
||||||
'include' '<' filename '>' <skip: '[ \t]*'> "\n"
|
'include' '<' filename '>' <skip: '[ \t]*'> "\n"
|
||||||
{ $return = "\nInclude system file $item{filename}.\n"; }
|
{ $return = "\nInclude the header $item{filename}.\n"; }
|
||||||
| 'include' '"' filename '"' <skip: '[ \t]*'> "\n"
|
| 'include' '"' filename '"' <skip: '[ \t]*'> "\n"
|
||||||
{ $return = "\nInclude user file $item{filename}.\n"; }
|
{ $return = "\nInclude the source file $item{filename}.\n"; }
|
||||||
| 'include' token
|
| 'include' token
|
||||||
{ $return = "\nImport code noted by the token $item{token}.\n"; }
|
{ $return = "\nImport code noted by the token $item{token}.\n"; }
|
||||||
|
|
||||||
@ -669,11 +669,7 @@ declaration:
|
|||||||
my ($first_qualifier, $first_initializer);
|
my ($first_qualifier, $first_initializer);
|
||||||
my $first_identifier = shift @args;
|
my $first_identifier = shift @args;
|
||||||
|
|
||||||
if (not length $first_identifier) {
|
my @identifiers = ($first_identifier) unless not length $first_identifier;
|
||||||
$first_identifier = 'there';
|
|
||||||
}
|
|
||||||
|
|
||||||
my @identifiers = ($first_identifier);
|
|
||||||
|
|
||||||
my $next_arg = shift @args;
|
my $next_arg = shift @args;
|
||||||
if ($next_arg =~ m/initialized/) {
|
if ($next_arg =~ m/initialized/) {
|
||||||
@ -739,7 +735,7 @@ declaration:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$return .= ' as ';
|
$return .= ' as ' unless not @identifiers;
|
||||||
|
|
||||||
if ($first_qualifier) {
|
if ($first_qualifier) {
|
||||||
if ($first_qualifier =~ /bit\-field/) {
|
if ($first_qualifier =~ /bit\-field/) {
|
||||||
@ -753,7 +749,8 @@ declaration:
|
|||||||
$first_qualifier =~ s/pointer/pointers/;
|
$first_qualifier =~ s/pointer/pointers/;
|
||||||
$first_qualifier =~ s/an array/arrays/;
|
$first_qualifier =~ s/an array/arrays/;
|
||||||
}
|
}
|
||||||
$return .= "$first_qualifier $item{declaration_specifiers}";
|
$return .= "$first_qualifier";
|
||||||
|
$return .= $item{declaration_specifiers} if $item{declaration_specifiers};
|
||||||
} else {
|
} else {
|
||||||
if (@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
|
if (@identifiers == 1 and $item{declaration_specifiers} !~ /^(a|an)\s+/) {
|
||||||
$return .= $item{declaration_specifiers} =~ m/^[aeiouy]/ ? 'an ' : 'a ';
|
$return .= $item{declaration_specifiers} =~ m/^[aeiouy]/ ? 'an ' : 'a ';
|
||||||
@ -777,7 +774,7 @@ declaration:
|
|||||||
$return .= ' as another name for ';
|
$return .= ' as another name for ';
|
||||||
push @typedefs, @identifiers;
|
push @typedefs, @identifiers;
|
||||||
} else {
|
} else {
|
||||||
$return .= ' as ';
|
$return .= ' as ' unless not @identifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($first_qualifier) {
|
if ($first_qualifier) {
|
||||||
|
Loading…
Reference in New Issue
Block a user