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

applets/c2english: make some rules more aware of expressions

This commit is contained in:
Pragmatic Software 2024-07-10 12:46:56 -07:00
parent c1847efc35
commit 6ac157d42d
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 13 additions and 13 deletions

View File

@ -423,7 +423,7 @@ expression_statement:
labeled_statement: labeled_statement:
identifier ':' statement[context => 'label'] (';')(?) identifier ':' statement[context => 'label'] (';')(?)
{ "Let there be a label $item{identifier}.\n$item{statement}" } { "Let there be a label $item{identifier}.\n$item{statement}" }
| ('case' constant_expression | ('case' constant_expression[context => 'constant expression']
{ $return = $item{constant_expression} } { $return = $item{constant_expression} }
':')(s) ':')(s)
{ {
@ -450,7 +450,7 @@ labeled_statement:
{ "In the default case, ^L$item{statement}" } { "In the default case, ^L$item{statement}" }
expression: expression:
<leftop: assignment_expression ',' assignment_expression> <leftop: assignment_expression[context => 'expression'] ',' assignment_expression[context => 'assignment expression']>
{ {
if ($arg{context} eq 'for increment statement' if ($arg{context} eq 'for increment statement'
or $arg{context} eq 'for init') { or $arg{context} eq 'for init') {
@ -465,7 +465,7 @@ expression:
assignment_expression: assignment_expression:
unary_expression[context => 'assignment expression'] unary_expression[context => 'assignment expression']
assignment_operator assignment_operator[context => 'assignment expression']
assignment_expression[context => 'assignment expression'] assignment_expression[context => 'assignment expression']
{ {
my $assignment_expression = $item{assignment_expression}; my $assignment_expression = $item{assignment_expression};
@ -480,10 +480,10 @@ assignment_expression:
$return = "$item{unary_expression} $assignment_operator $assignment_expression"; $return = "$item{unary_expression} $assignment_operator $assignment_expression";
} }
} }
| conditional_expression | conditional_expression[context => 'conditional expression']
conditional_expression: conditional_expression:
logical_OR_AND_expression conditional_ternary_expression logical_OR_AND_expression[context => 'expression'] conditional_ternary_expression[context => 'expression']
{ {
if ($item{conditional_ternary_expression}) { if ($item{conditional_ternary_expression}) {
my $op1 = $item{conditional_ternary_expression}->[0]; my $op1 = $item{conditional_ternary_expression}->[0];
@ -503,7 +503,7 @@ conditional_expression:
} }
conditional_ternary_expression: conditional_ternary_expression:
'?' expression ':' conditional_expression '?' expression[context => 'expression'] ':' conditional_expression[context => 'expression']
{ [$item{expression}, $item{conditional_expression}] } { [$item{expression}, $item{conditional_expression}] }
| {""} | {""}
@ -620,13 +620,13 @@ assignment_operator:
} }
constant_expression: constant_expression:
conditional_expression conditional_expression[context => 'expression']
logical_OR_AND_expression: logical_OR_AND_expression:
<leftop: <leftop:
rel_add_mul_shift_expression rel_add_mul_shift_expression[context => 'expression']
log_OR_AND_bit_or_and_eq log_OR_AND_bit_or_and_eq[context => 'expression']
rel_add_mul_shift_expression[context => 'logical_OR_AND_expression']> rel_add_mul_shift_expression[context => 'expression']>
{ {
my $expression = join('', @{$item[1]}); my $expression = join('', @{$item[1]});
if($arg{context} =~ /initializer expression$/ if($arg{context} =~ /initializer expression$/
@ -683,7 +683,7 @@ unary_operator:
rel_add_mul_shift_expression: rel_add_mul_shift_expression:
cast_expression ...';' cast_expression ...';'
{ $item{cast_expression} } { $item{cast_expression} }
| <leftop: cast_expression rel_mul_add_ex_op cast_expression> | <leftop: cast_expression rel_mul_add_ex_op[context => 'expression'] cast_expression>
{ join('', @{$item[1]}) } { join('', @{$item[1]}) }
closure: closure:

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script # These are set by the /misc/update_version script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 4766, BUILD_REVISION => 4767,
BUILD_DATE => "2024-06-29", BUILD_DATE => "2024-07-10",
}; };
sub initialize {} sub initialize {}