3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-30 07:59:42 +01:00

CGrammar: Improve labels and goto

This commit is contained in:
Pragmatic Software 2014-06-14 19:13:53 +00:00
parent 392cbfb5d1
commit bf9586b6a8
2 changed files with 8 additions and 6 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 => 638,
BUILD_REVISION => 639,
BUILD_DATE => "2014-06-14",
};

View File

@ -368,9 +368,7 @@ jump_statement:
| 'goto' <commit> identifier ';' comment(?)
{
$return = "Go to the label named $item{identifier}.\n";
if ($item{comment}) {
$return .= $item{comment};
}
$return .= join('', @{$item{'comment(?)'}});
}
expression_statement:
@ -378,14 +376,18 @@ expression_statement:
{
my $item_expression = join('',@{$item[1]});
if (!$item_expression) {
$return = "Do nothing.\n";
if($arg{context} eq 'label') {
return "";
} else {
$return = "Do nothing.\n";
}
} else {
$return = $item_expression.".\n" ;
}
}
labeled_statement:
identifier ':' statement
identifier ':' statement[context => 'label'] (';')(?)
{ $return = "Let there be a label $item{identifier}.\n$item{statement}"; }
| 'case' constant_expression ':' statement[context => 'case']
{ $return = "When it has the value $item{constant_expression}, ^L$item{statement}"; }