mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
CGrammar: Add "result of the expression" to assignment expressions with spaces; remove extraneous trailing "Do nothing"
This commit is contained in:
parent
de375e63a1
commit
da7a827c01
@ -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 => 741,
|
BUILD_REVISION => 742,
|
||||||
BUILD_DATE => "2014-07-21",
|
BUILD_DATE => "2014-07-21",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ if($code =~ s/^-f\s+//) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my ($has_function, $has_main, $got_nomain);
|
my ($has_function, $has_main, $got_nomain);
|
||||||
my $prelude_base = "#define _XOPEN_SOURCE 9001\n#define __USE_XOPEN\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <math.h>\n#include <limits.h>\n#include <sys/types.h>\n#include <stdint.h>\n#include <errno.h>\n#include <ctype.h>\n#include <assert.h>\n#include <stdnoreturn.h>\n#include <stdbool.h>\n#include <stdalign.h>\n#define _Atomic\n#define _Static_assert(a, b)\n\n";
|
my $prelude_base = "#define _XOPEN_SOURCE 9001\n#define __USE_XOPEN\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <math.h>\n#include <limits.h>\n#include <sys/types.h>\n#include <stdint.h>\n#include <errno.h>\n#include <ctype.h>\n#include <assert.h>\n#include <stdnoreturn.h>\n#include <stdbool.h>\n#include <stdalign.h>\n#include <time.h>\n#define _Atomic\n#define _Static_assert(a, b)\n\n";
|
||||||
my $prelude = $prelude_base;
|
my $prelude = $prelude_base;
|
||||||
|
|
||||||
print "code before: [$code]\n" if $debug;
|
print "code before: [$code]\n" if $debug;
|
||||||
@ -290,8 +290,8 @@ $code =~ s/\|n/\n/g;
|
|||||||
$code =~ s/^\s+//;
|
$code =~ s/^\s+//;
|
||||||
$code =~ s/\s+$//;
|
$code =~ s/\s+$//;
|
||||||
$code =~ s/;\s*;\n/;\n/gs;
|
$code =~ s/;\s*;\n/;\n/gs;
|
||||||
$code =~ s/;(\s*\/\*.*?\*\/\s*);\n/;$1/gs;
|
$code =~ s/(;)?(\s*\/\*.*?\*\/\s*);\n/$1$2/gs;
|
||||||
$code =~ s/;(\s*\/\/.*?\s*);\n/;$1/gs;
|
$code =~ s/(;)?(\s*\/\/.*?\s*);\n/$1$2/gs;
|
||||||
$code =~ s/({|})\n\s*;\n/$1\n/gs;
|
$code =~ s/({|})\n\s*;\n/$1\n/gs;
|
||||||
$code =~ s/(?:\n\n)+/\n\n/g;
|
$code =~ s/(?:\n\n)+/\n\n/g;
|
||||||
|
|
||||||
|
@ -467,6 +467,7 @@ assignment_expression:
|
|||||||
|
|
||||||
if (ref $assignment_operator eq 'ARRAY') {
|
if (ref $assignment_operator eq 'ARRAY') {
|
||||||
$return .= "${$item{assignment_operator}}[0] $item{unary_expression} ";
|
$return .= "${$item{assignment_operator}}[0] $item{unary_expression} ";
|
||||||
|
${$item{assignment_operator}}[1] =~ s/the value/the result of the expression/ if $assignment_expression =~ / /;
|
||||||
$return .= "${$item{assignment_operator}}[1] " if $assignment_expression !~ /the result of/;
|
$return .= "${$item{assignment_operator}}[1] " if $assignment_expression !~ /the result of/;
|
||||||
$return .= $assignment_expression;
|
$return .= $assignment_expression;
|
||||||
} else {
|
} else {
|
||||||
@ -1840,7 +1841,7 @@ comment_cxx:
|
|||||||
$return =~ s|^//\s*||;
|
$return =~ s|^//\s*||;
|
||||||
$return =~ s/\n*$//;
|
$return =~ s/\n*$//;
|
||||||
$return =~ s/"/\\"/g;
|
$return =~ s/"/\\"/g;
|
||||||
$return = "\nQuick comment: \"$return\".\n";
|
$return = "\nA quick comment: \"$return\".\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
constant:
|
constant:
|
||||||
|
Loading…
Reference in New Issue
Block a user