report_error_count
);
+##############################
+# A number of "constants"
+
our ($C_group_rex, $C_arg);
-BEGIN {
- # Group in C (no support for comments or literals)
- $C_group_rex = qr/ [({\[]
- (?: (?> [^()\[\]{}]+ ) | (??{ $C_group_rex }) )*
- [)}\]] /x;
- # Chunk in C without comma at toplevel (no comments):
- $C_arg = qr/ (?: (?> [^()\[\]{},"']+ )
- | (??{ $C_group_rex })
- | " (?: (?> [^\\"]+ )
- | \\.
- )* " # String literal
- | ' (?: (?> [^\\']+ ) | \\. )* ' # Char literal
- )* /xs;
-}
+# Group in C (no support for comments or literals)
+$C_group_rex = qr/ [({\[]
+ (?: (?> [^()\[\]{}]+ ) | (??{ $C_group_rex }) )*
+ [)}\]] /x;
+# Chunk in C without comma at toplevel (no comments):
+$C_arg = qr/ (?: (?> [^()\[\]{},"']+ )
+ | (??{ $C_group_rex })
+ | " (?: (?> [^\\"]+ )
+ | \\.
+ )* " # String literal
+ | ' (?: (?> [^\\']+ ) | \\. )* ' # Char literal
+ )* /xs;
+
+# "impossible" keyword (multiple newline)
+my $END = "!End!\n\n";
+# Match an XS Keyword
+my $BLOCK_regexp = '\s*(' . $ExtUtils::ParseXS::Constants::XSKeywordsAlternation . "|$END)\\s*:";
+
+
sub new {
return bless {} => shift;
$self->{typemap} = process_typemaps( $args{typemap}, $pwd );
- my $END = "!End!\n\n"; # "impossible" keyword (multiple newline)
-
- # Match an XS keyword
- $self->{BLOCK_re} = '\s*(' .
- join('|' => @ExtUtils::ParseXS::Constants::XSKeywords) .
- "|$END)\\s*:";
-
# Since at this point we're ready to begin printing to the output file and
# reading from the input file, I want to get as much data as possible into
# the proto-object $self. That means assigning to $self and elements of
next;
}
last if $_ eq "$END:";
- $self->death(/^$self->{BLOCK_re}/o ? "Misplaced '$1:'" : "Junk at end of function ($_)");
+ $self->death(/^$BLOCK_regexp/o ? "Misplaced '$1:'" : "Junk at end of function ($_)");
}
print Q(<<"EOF") if $self->{except};
print("#line ", $self->{line_no}->[@{ $self->{line_no} } - @{ $self->{line} } -1], " \"",
escape_file_for_line_directive($self->{filepathname}), "\"\n")
if $self->{WantLineNumbers} && !/^\s*#\s*line\b/ && !/^#if XSubPPtmp/;
- for (; defined($_) && !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
+ for (; defined($_) && !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) {
print "$_\n";
$consumed_code .= "$_\n";
}
$_ = shift(@{ $self->{line} });
}
- for (; defined($_) && !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
+ for (; defined($_) && !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) {
$in .= "$_\n";
}
chomp $in;
sub INPUT_handler {
my $self = shift;
$_ = shift;
- for (; !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
+ for (; !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) {
last if /^\s*NOT_IMPLEMENTED_YET/;
next unless /\S/; # skip blank lines
$self->{have_OUTPUT} = 1;
$_ = shift;
- for (; !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
+ for (; !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) {
next unless /\S/;
if (/^\s*SETMAGIC\s*:\s*(ENABLE|DISABLE)\s*/) {
$self->{DoSetMagic} = ($1 eq "ENABLE" ? 1 : 0);
my $self = shift;
$_ = shift;
- for (; !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
+ for (; !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) {
next unless /\S/;
trim_whitespace($_);
push @{ $self->{Attributes} }, $_;
my $self = shift;
$_ = shift;
- for (; !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
+ for (; !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) {
next unless /\S/;
trim_whitespace($_);
$self->get_aliases($_) if $_;
my $self = shift;
$_ = shift;
- for (; !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
+ for (; !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) {
next unless /\S/;
trim_whitespace($_);
while ( s/^\s*([\w:"\\)\+\-\*\/\%\<\>\.\&\|\^\!\~\{\}\=]+)\s*//) {
$self->death("Error: Only 1 PROTOTYPE definition allowed per xsub")
if $self->{proto_in_this_xsub}++;
- for (; !/^$self->{BLOCK_re}/o; $_ = shift(@{ $self->{line} })) {
+ for (; !/^$BLOCK_regexp/o; $_ = shift(@{ $self->{line} })) {
next unless /\S/;
$specified = 1;
trim_whitespace($_);