3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-27 06:19:25 +01:00

compiler_vm: Remember last keyword when chaining together "and" statements in editor

This allows the more natural "replace 'a' with 'b' and 'c' with 'd'" syntax
rather than the previous syntax of "replace 'a' with 'b' and replace 'c' with 'd'"
This commit is contained in:
Pragmatic Software 2014-04-02 00:23:14 +00:00
parent 474f7ed168
commit 1ec463f021
2 changed files with 12 additions and 3 deletions

View File

@ -13,8 +13,8 @@ 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 => 535, BUILD_REVISION => 536,
BUILD_DATE => "2014-03-24", BUILD_DATE => "2014-04-01",
}; };
1; 1;

View File

@ -253,12 +253,16 @@ if($subcode =~ m/^\s*(?:and\s+)?(run|paste)\s*$/i) {
my @replacements; my @replacements;
my $prevchange = $last_code[0]; my $prevchange = $last_code[0];
my $got_changes = 0; my $got_changes = 0;
my $last_keyword;
while(1) { while(1) {
$got_sub = 0; $got_sub = 0;
#$got_changes = 0; #$got_changes = 0;
$subcode =~ s/^\s*and\s+'/and $last_keyword '/ if defined $last_keyword;
if($subcode =~ m/^\s*(and)?\s*remove \s*([^']+)?\s*'/) { if($subcode =~ m/^\s*(and)?\s*remove \s*([^']+)?\s*'/) {
$last_keyword = 'remove';
my $modifier = 'first'; my $modifier = 'first';
$subcode =~ s/^\s*(and)?\s*//; $subcode =~ s/^\s*(and)?\s*//;
@ -283,6 +287,7 @@ if($subcode =~ m/^\s*(?:and\s+)?(run|paste)\s*$/i) {
} }
if($subcode =~ s/^\s*(and)?\s*prepend '//) { if($subcode =~ s/^\s*(and)?\s*prepend '//) {
$last_keyword = 'prepend';
$subcode = "'$subcode"; $subcode = "'$subcode";
my ($e, $r) = extract_delimited($subcode, "'"); my ($e, $r) = extract_delimited($subcode, "'");
@ -314,6 +319,7 @@ if($subcode =~ m/^\s*(?:and\s+)?(run|paste)\s*$/i) {
} }
if($subcode =~ s/^\s*(and)?\s*append '//) { if($subcode =~ s/^\s*(and)?\s*append '//) {
$last_keyword = 'append';
$subcode = "'$subcode"; $subcode = "'$subcode";
my ($e, $r) = extract_delimited($subcode, "'"); my ($e, $r) = extract_delimited($subcode, "'");
@ -345,6 +351,7 @@ if($subcode =~ m/^\s*(?:and\s+)?(run|paste)\s*$/i) {
} }
if($subcode =~ m/^\s*(and)?\s*replace\s*([^']+)?\s*'.*'\s*with\s*'.*?'/i) { if($subcode =~ m/^\s*(and)?\s*replace\s*([^']+)?\s*'.*'\s*with\s*'.*?'/i) {
$last_keyword = 'replace';
$got_sub = 1; $got_sub = 1;
my $modifier = 'first'; my $modifier = 'first';
@ -406,6 +413,7 @@ if($subcode =~ m/^\s*(?:and\s+)?(run|paste)\s*$/i) {
} }
if($subcode =~ m/^\s*(and)?\s*s\/.*\//) { if($subcode =~ m/^\s*(and)?\s*s\/.*\//) {
$last_keyword = undef;
$got_sub = 1; $got_sub = 1;
$subcode =~ s/^\s*(and)?\s*s//; $subcode =~ s/^\s*(and)?\s*s//;
@ -970,7 +978,8 @@ if($output =~ m/^\s*$/) {
print FILE "$output\n"; print FILE "$output\n";
} }
$output =~ s/In file included from prog.c:\d+:\d+:\s*//msg; $output =~ s/In file included from .*?:\d+:\d+.\s*from prog.c:\d+:\s*//msg;
$output =~ s/In file included from .*?:\d+:\d+.\s*//msg;
$output =~ s/prog: prog.c:\d+: [^:]+: Assertion/Assertion/g; $output =~ s/prog: prog.c:\d+: [^:]+: Assertion/Assertion/g;
$output =~ s,/usr/include/[^:]+:\d+:\d+:\s+,,g; $output =~ s,/usr/include/[^:]+:\d+:\d+:\s+,,g;