3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

compiler_vm: extract_codeblock doesn't do what I thought; also improved handling of #defines

This commit is contained in:
Pragmatic Software 2011-02-04 02:50:52 +00:00
parent d28903f05f
commit 6552390c5e

View File

@ -5,7 +5,7 @@ use strict;
use feature qw(switch); use feature qw(switch);
use IPC::Open2; use IPC::Open2;
use Text::Balanced qw(extract_codeblock extract_delimited); use Text::Balanced qw(extract_bracketed extract_delimited);
use IO::Socket; use IO::Socket;
use LWP::UserAgent; use LWP::UserAgent;
@ -578,7 +578,7 @@ if($lang eq 'C' or $lang eq 'C99' or $lang eq 'C++') {
my $has_main = 0; my $has_main = 0;
my $prelude = ''; my $prelude = '';
$prelude = "$1$2" if $precode =~ s/^\s*(#.*)(#.*?[>\n])//s; $prelude = "$1$2" if $precode =~ s/^\s*(#.*)(#.*?>\s*\n|#.*?\n)//s;
my $preprecode = $precode; my $preprecode = $precode;
@ -595,7 +595,7 @@ if($lang eq 'C' or $lang eq 'C99' or $lang eq 'C++') {
$precode =~ s/([ a-zA-Z0-9\_\*\[\]]+)\s+([a-zA-Z0-9_*]+)\s*\((.*?)\)\s*({.*)//; $precode =~ s/([ a-zA-Z0-9\_\*\[\]]+)\s+([a-zA-Z0-9_*]+)\s*\((.*?)\)\s*({.*)//;
} }
my @extract = extract_codeblock($potential_body, '{}'); my @extract = extract_bracketed($potential_body, '{}');
my $body; my $body;
if(not defined $extract[0]) { if(not defined $extract[0]) {
$output .= "error: unmatched brackets for function '$ident';\n"; $output .= "error: unmatched brackets for function '$ident';\n";