mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-19 10:29:30 +01:00
CGrammar: Fix handling 0 as conditional in for loop
This commit is contained in:
parent
38b6edf656
commit
bea4480cf3
@ -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 => 725,
|
BUILD_REVISION => 726,
|
||||||
BUILD_DATE => "2014-07-10",
|
BUILD_DATE => "2014-07-10",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ compound_statement:
|
|||||||
and $arg{context} ne 'case'
|
and $arg{context} ne 'case'
|
||||||
and $arg{context} ne 'function definition statement'
|
and $arg{context} ne 'function definition statement'
|
||||||
and $arg{context} ne 'function definition') {
|
and $arg{context} ne 'function definition') {
|
||||||
$return .= "End $arg{context}.\n";
|
$return .= "End $arg{context}.";
|
||||||
}
|
}
|
||||||
1;
|
1;
|
||||||
}
|
}
|
||||||
@ -259,14 +259,22 @@ iteration_statement:
|
|||||||
$return .= "Prepare a loop by ^L$initialization, then ^L";
|
$return .= "Prepare a loop by ^L$initialization, then ^L";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($expression) {
|
if (length $expression) {
|
||||||
|
if ($expression =~ /^(\d+)$/) {
|
||||||
|
if($expression == 0) {
|
||||||
|
$return .= "Repeatedly never ^L";
|
||||||
|
} else {
|
||||||
|
$return .= "Repeatedly ^L";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
my $expression = ::istrue $expression;
|
my $expression = ::istrue $expression;
|
||||||
$return .= "For as long as ^L$expression, ^L";
|
$return .= "For as long as ^L$expression, ^L";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$return .= "Repeatedly ^L";
|
$return .= "Repeatedly ^L";
|
||||||
}
|
}
|
||||||
|
|
||||||
$return .= "$item{statement}.\n";
|
$return .= $item{statement};
|
||||||
|
|
||||||
if ($increment) {
|
if ($increment) {
|
||||||
$return =~ s/End for loop.$//;
|
$return =~ s/End for loop.$//;
|
||||||
@ -277,7 +285,7 @@ iteration_statement:
|
|||||||
{
|
{
|
||||||
if ($item{expression} =~ /(^\d+$)/) {
|
if ($item{expression} =~ /(^\d+$)/) {
|
||||||
if ($1 == 0) {
|
if ($1 == 0) {
|
||||||
$return = "Never ^L";
|
$return = "Repeatedly never ^L";
|
||||||
} else {
|
} else {
|
||||||
$return = "Repeatedly ^L";
|
$return = "Repeatedly ^L";
|
||||||
}
|
}
|
||||||
@ -375,7 +383,7 @@ expression_statement:
|
|||||||
expression[context => "$arg{context}|statement"](?) ';'
|
expression[context => "$arg{context}|statement"](?) ';'
|
||||||
{
|
{
|
||||||
my $expression = join('',@{$item[1]});
|
my $expression = join('',@{$item[1]});
|
||||||
if (!$expression) {
|
if (not length $expression) {
|
||||||
if ($arg{context} eq 'label'
|
if ($arg{context} eq 'label'
|
||||||
or $arg{context} eq 'for init'
|
or $arg{context} eq 'for init'
|
||||||
or $arg{context} eq 'for conditional') {
|
or $arg{context} eq 'for conditional') {
|
||||||
|
Loading…
Reference in New Issue
Block a user