Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use v5.35; my $code = ""; while(<>) { if (/ExecuteTest\(\n$/) { # First line of the test die "nested?" if $code ne ""; $code = $_; } elsif (/^ {4}\);/) { # Last line of the test $code .= $_; if ($code !~ /\)"/ and $code !~ /\)\\"/ and $code =~ / ^ (?<head> \ *(auto\ publicProgram\ =\ )?ExecuteTest\( ) \n (?<body> (?&CBotOrComment) (\n (?&CBotOrComment) )* ) (?<tail> # Error code ( ,\n \s*[a-zA-Z0-9]+ )? \s* \n\ {4}\);\n ) $ (?(DEFINE) (?<CBotOrComment> # A quoted line of CBot code or a C++ comment [ ]{8}" ([^\\]|\\"|\\'|\\\\)* # Allow only the following escapes: \", \' and \\ (\\n)?" | [ ]{8}\/\/.* ) ) /x) { my $head = $+{head} . "R\"("; my $body = $+{body}; my $tail = $+{tail}; if ($body =~ "\n") { $body =~ s/^([ ]{8})"/$1/mg; # Strip the quote at the begining $body =~ s/(\\n)?"(\n?)$/$2/mg; # Strip the quote at the end # Implement escape seqences $body =~ s/\\"/"/g; $body =~ s/\\'/'/g; $body =~ s/\\\\/\\/g; if ( $tail eq "\n );\n" ) { $tail = "\n )\");\n"; } else { $body .= "\n )\""; } $code = $head . "\n" . $body . $tail; } } else { #print $code; # DEBUG } print $code; $code = ""; } else { if ($code eq "") { print $_; } else { $code .= $_; } } }
- Loading branch information