3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 11:42:35 +01:00

CGrammar: Improve handling of space seperator in declaration initializers; fix issue with typedefs starting with a type specifier

This commit is contained in:
Pragmatic Software 2014-07-08 03:28:51 +00:00
parent 0c8078c6db
commit 029cc1ec7a
2 changed files with 32 additions and 35 deletions

View File

@ -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 => 719, BUILD_REVISION => 720,
BUILD_DATE => "2014-07-07", BUILD_DATE => "2014-07-07",
}; };

View File

@ -681,14 +681,12 @@ declaration:
my @identifiers = ($first_identifier) unless not length $first_identifier; my @identifiers = ($first_identifier) unless not length $first_identifier;
my $sep = '';
foreach my $arg (@args) { foreach my $arg (@args) {
if ($arg =~ /initialized/) { if ($arg =~ /initialized/) {
$first_initializer .= "$sep$arg"; $first_initializer .= (length $first_initializer ? ' ' : '') . $arg;
} else { } else {
$first_qualifier .= "$sep$arg"; $first_qualifier .= (length $first_qualifier ? ' ' : '') . $arg;
} }
$sep = ' ';
} }
my @initializers; my @initializers;
@ -702,14 +700,12 @@ declaration:
my ($qualifier, $initializer); my ($qualifier, $initializer);
my $identifier = shift @args; my $identifier = shift @args;
my $sep = '';
foreach my $arg (@args) { foreach my $arg (@args) {
if ($arg =~ /initialized/) { if ($arg =~ /initialized/) {
$initializer .= "$sep$arg"; $initializer .= (length $initializer ? ' ' : '') . $arg;
} else { } else {
$qualifier .= "$sep$arg"; $qualifier .= (length $qualifier ? ' ' : '') . $arg;
} }
$sep = ' ';
} }
next unless $qualifier eq $first_qualifier; next unless $qualifier eq $first_qualifier;
@ -817,7 +813,7 @@ declaration:
$comma = ', '; $comma = ', ';
$and = ' and '; $and = ' and ';
} else { } else {
$initializer =~ s/^\s*initialized to \^L//; $initializer =~ s/^initialized to \^L//;
$return .= "$and$identifier to $initializer"; $return .= "$and$identifier to $initializer";
if ($i < @initializers - 2) { if ($i < @initializers - 2) {
$and = $comma = ', '; $and = $comma = ', ';
@ -1611,31 +1607,32 @@ atomic_type_specifier:
{ $return = "atomic $item{type_name}"; } { $return = "atomic $item{type_name}"; }
type_specifier: type_specifier:
<skip:''> /\s*/ ('void' | 'double' | 'float' | 'char' | 'short' | 'int' | 'long' <skip:''> /\s*/
| 'signed' | 'unsigned' (typedef_name | 'void' | 'double' | 'float' | 'char' | 'short' | 'int' | 'long'
| 'FILE' | 'fpos_t' | 'signed' | 'unsigned'
| 'bool' | '_Bool' | 'FILE' | 'fpos_t'
| '_Complex' | '_Imaginary' | 'bool' | '_Bool'
| 'int_fast8_t' | 'int_fast16_t' | 'int_fast24_t' | 'int_fast32_t' | 'int_fast64_t' | 'int_fast128_t' | '_Complex' | '_Imaginary'
| 'uint_fast8_t' | 'uint_fast16_t' | 'uint_fast24_t' | 'uint_fast32_t' | 'uint_fast64_t' | 'uint_fast128_t' | 'int_fast8_t' | 'int_fast16_t' | 'int_fast24_t' | 'int_fast32_t' | 'int_fast64_t' | 'int_fast128_t'
| 'int_least8_t' | 'int_least16_t' | 'int_least24_t' | 'int_least32_t' | 'int_least64_t' | 'int_least128_t' | 'uint_fast8_t' | 'uint_fast16_t' | 'uint_fast24_t' | 'uint_fast32_t' | 'uint_fast64_t' | 'uint_fast128_t'
| 'uint_least8_t' | 'uint_least16_t' | 'uint_least24_t' | 'uint_least32_t' | 'uint_least64_t' | 'uint_least128_t' | 'int_least8_t' | 'int_least16_t' | 'int_least24_t' | 'int_least32_t' | 'int_least64_t' | 'int_least128_t'
| 'int8_t' | 'int16_t' | 'int24_t' | 'int32_t' | 'int64_t' | 'int128_t' | 'uint_least8_t' | 'uint_least16_t' | 'uint_least24_t' | 'uint_least32_t' | 'uint_least64_t' | 'uint_least128_t'
| 'uint8_t' | 'uint16_t' | 'uint24_t' | 'uint32_t' | 'uint64_t' | 'uint128_t' | 'int8_t' | 'int16_t' | 'int24_t' | 'int32_t' | 'int64_t' | 'int128_t'
| 'intmax_t' | 'uintmax_t' | 'uint8_t' | 'uint16_t' | 'uint24_t' | 'uint32_t' | 'uint64_t' | 'uint128_t'
| 'intptr_t' | 'uintptr_t' | 'ptrdiff_t' | 'intmax_t' | 'uintmax_t'
| 'sig_atomic_t' | 'intptr_t' | 'uintptr_t' | 'ptrdiff_t'
| 'wint_t' | 'wchar_t' | 'sig_atomic_t'
| 'size_t' | 'rsize_t' | 'max_align_t' | 'wint_t' | 'wchar_t'
| 'mbstate_t' | 'char16_t' | 'char32_t' | 'size_t' | 'rsize_t' | 'max_align_t'
| 'fenv_t' | 'fexcept_t' | 'mbstate_t' | 'char16_t' | 'char32_t'
| 'div_t' | 'ldiv_t' | 'lldiv_t' | 'imaxdiv_t' | 'fenv_t' | 'fexcept_t'
| 'cnd_t' | 'thrd_t' | 'tss_t' | 'mtx_t' | 'tss_dtor_t' | 'thrd_start_t' | 'once_flag' | 'div_t' | 'ldiv_t' | 'lldiv_t' | 'imaxdiv_t'
| 'clock_t' | 'time_t' | 'cnd_t' | 'thrd_t' | 'tss_t' | 'mtx_t' | 'tss_dtor_t' | 'thrd_start_t' | 'once_flag'
| <skip:'[\s]*'> struct_or_union_specifier | 'clock_t' | 'time_t'
| <skip:'[\s]*'> enum_specifier | <skip:'[\s]*'> struct_or_union_specifier
| <skip:'[\s]*'> atomic_type_specifier | <skip:'[\s]*'> enum_specifier
| typedef_name) .../\W/ | <skip:'[\s]*'> atomic_type_specifier
) .../\W/
{ $return = $item[3]; } { $return = $item[3]; }
typedef_name: typedef_name: