mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-18 14:30:40 +01:00
CGrammar: Improve labels and goto
This commit is contained in:
parent
392cbfb5d1
commit
bf9586b6a8
@ -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 => 638,
|
BUILD_REVISION => 639,
|
||||||
BUILD_DATE => "2014-06-14",
|
BUILD_DATE => "2014-06-14",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -368,9 +368,7 @@ jump_statement:
|
|||||||
| 'goto' <commit> identifier ';' comment(?)
|
| 'goto' <commit> identifier ';' comment(?)
|
||||||
{
|
{
|
||||||
$return = "Go to the label named $item{identifier}.\n";
|
$return = "Go to the label named $item{identifier}.\n";
|
||||||
if ($item{comment}) {
|
$return .= join('', @{$item{'comment(?)'}});
|
||||||
$return .= $item{comment};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expression_statement:
|
expression_statement:
|
||||||
@ -378,14 +376,18 @@ expression_statement:
|
|||||||
{
|
{
|
||||||
my $item_expression = join('',@{$item[1]});
|
my $item_expression = join('',@{$item[1]});
|
||||||
if (!$item_expression) {
|
if (!$item_expression) {
|
||||||
$return = "Do nothing.\n";
|
if($arg{context} eq 'label') {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
$return = "Do nothing.\n";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$return = $item_expression.".\n" ;
|
$return = $item_expression.".\n" ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
labeled_statement:
|
labeled_statement:
|
||||||
identifier ':' statement
|
identifier ':' statement[context => 'label'] (';')(?)
|
||||||
{ $return = "Let there be a label $item{identifier}.\n$item{statement}"; }
|
{ $return = "Let there be a label $item{identifier}.\n$item{statement}"; }
|
||||||
| 'case' constant_expression ':' statement[context => 'case']
|
| 'case' constant_expression ':' statement[context => 'case']
|
||||||
{ $return = "When it has the value $item{constant_expression}, ^L$item{statement}"; }
|
{ $return = "When it has the value $item{constant_expression}, ^L$item{statement}"; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user