3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-19 10:29:30 +01:00

CGrammar: Update compound-statements to C11's block-item-list mixing declarations and statements

This commit is contained in:
Pragmatic Software 2014-07-02 17:54:21 +00:00
parent 07f9ef6120
commit 469e16ce28
2 changed files with 13 additions and 10 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 => 694,
BUILD_REVISION => 695,
BUILD_DATE => "2014-07-02",
};

View File

@ -162,20 +162,23 @@ function_definition:
$return .= join('', @{$item{'compound_statement(?)'}});
}
block_item_list:
block_item(s)
{ $return = join('', @{$item{'block_item(s)'}}); }
block_item:
declaration
| statement
compound_statement:
'{' declaration_list(?) statement_list(?) '}'
'{' block_item_list(s?) '}'
{
my $declaration_list = join('',@{$item{'declaration_list(?)'}});
my $statement_list = join('',@{$item{'statement_list(?)'}});
my $block_items = join('', @{$item{'block_item_list(s?)'}});
$return = "Begin new block.\n" if not $arg{context};
if ($declaration_list) {
$return .= $declaration_list;
}
if ($statement_list ) {
$return .= $statement_list;
if ($block_items) {
$return .= $block_items;
} else {
$return .= "Do nothing.\n";
}