App-UnifdefPlus
view release on metacpan or search on metacpan
lib/UnifdefPlus.pm view on Meta::CPAN
$param += $1; # associate any trailing whitespaces with previous param
push @params, $param;
$rsstate = max($rsstate,$paramRss);
print " -- dbg: after max: ".$rsstate."\n";
$remaining =~ s/^\,(.*)\)$/$1/s; #strip next comma, and continue
}
return (\@params, $rsstate);
}
sub parseFuncMacro {
my $self = shift;
my $expr = shift;
my $lang = $self->{lang};
my $WS = $EXPR->{$lang}->{WHITESPACE};
if ($expr =~ /^($WS)(\w+)(\s*)(\(.*)$/) {
my $ws_bm = $1;
my $macroName = $2;
my $ws_am = $3;
my $rest = $4;
lib/UnifdefPlus.pm view on Meta::CPAN
$rss_o1 = max(RSS_SIMPLIFIED, $notOperand_rss);
}
else {
$operand1 = "!" . $ws_an . $notOperand;
$rss_o1 = $notOperand_rss;
}
}
# test for function-like macro:
elsif ( my ($ws_bm, $macro, $ws_am, $params, $remainder2) =
$self->parseFuncMacro($string1)) {
#simplify expression within braces
print DBGOUT "$dbgStr ... macro: .$macro.$params.\n" if $self->{dbg};
my ( $sparams, $remainder3, $sparams_rss, $sparams_ns );
if ( $params =~ /^($WS)$/ ) {
$sparams_ns = $params;
$sparams = $params;
$remainder3 = "";
$sparams_rss = RSS_UNCHANGED;
}
else {
lib/UnifdefPlus.pm view on Meta::CPAN
my ($brace,$remainder) = extract_bracketed($tmp, '("){"}');
return ("\$(".$prefix.$term.")", $rss) if !$remainder;
}
#term starts and ends in constant -- we can remove the strip keyword:
return ($term,max($rss,RSS_SIMPLIFIED));
}
my %makefileMacroSimplifiers = (
"or" => \&makefileSimplifyOr,
"and" => \&makefileSimplifyAnd,
"strip" => \&makefileSimplifyStrip,
# "if" => \&makefileSimplifyAnd,
);
#returns true if a variable is guarenteed to not be blank (i.e. $(FOO)_xx, will never be blank)
sub isMakefileExprNonBlank {
my $self=shift;
lib/UnifdefPlus.pm view on Meta::CPAN
my $dummy;
my @parmsOut = ();
$rss = RSS_UNCHANGED;
foreach (@parms_ns) {
my ($simplified,$dummy,$rssParm,$orig) = makefileSimplifyExpr($self, $_,$currentOpPrec,$level);
push @parms, { orig => $_, rss => $rssParm, simplified => $simplified };
}
# OK, now handle function....
if (exists $makefileMacroSimplifiers{$macroName}) {
my $method = $makefileMacroSimplifiers{$macroName};
my ($simplified, $newRss) = $self->$method($macroName.$ws1, \@parms);
$rss = max($rss,$newRss);
if ((!defined $simplified) or ($newRss == RSS_UNCHANGED)) {
$simplifiedExpr .= '$'.$openBrace.$braceExpr.$closeBrace;
} else {
$simplifiedExpr .= $simplified;
}
} else {
# unknown function...
for my $parmRef (@parms) {
( run in 0.525 second using v1.01-cache-2.11-cpan-49f99fa48dc )