--- a/sbsv1_os/e32toolp/e32util/armasm2as.pl Mon Jun 21 18:05:07 2010 +0100
+++ b/sbsv1_os/e32toolp/e32util/armasm2as.pl Wed Jun 23 15:48:26 2010 +0100
@@ -290,12 +290,13 @@
$val =~ s/\{FALSE\}/(0)/g;
my @lops = split( /(\s*\:LAND\:\s*|\s*\:LOR\:\s*|\s*\:LNOT\:\s*|\s*\:DEF\:\s*|\s*\(\s*|\s*\)\s*)/, $val );
- my @lops2;
foreach (@lops) {
s/\s*\:LAND\:\s*/\:LAND\:/go;
s/\s*\:LOR\:\s*/\:LOR\:/go;
s/\s*\:LNOT\:\s*/\:LNOT\:/go;
s/\s*\:DEF\:\s*/\:DEF\:/go;
+ s/\s*\(\s*/\(/go;
+ s/\s*\)\s*/\)/go;
}
my @lops2;
while (scalar (@lops)) {
@@ -322,12 +323,28 @@
while (scalar (@lops2)) {
my $x = shift @lops2;
if ($x eq ':LNOT:') {
- my $operand;
- while (1) {
+ my $operand = shift @lops2;
+ while (@lops2 && $operand =~ /^\s*$/) {
$operand = shift @lops2;
- last if ($operand !~ /^\s*$/);
}
- push @lops3, "(0==($operand))";
+ if ($operand eq '(') {
+ my $balance = 1;
+ my $compound = $operand;
+ while($balance > 0 && @lops2) {
+ $operand = shift @lops2;
+ if ($operand eq '(') {
+ ++$balance;
+ }
+ elsif ($operand eq ')') {
+ --$balance;
+ }
+ $compound .= $operand;
+ }
+ push @lops3, "(0==$compound)";
+ }
+ else {
+ push @lops3, "(0==($operand))";
+ }
} else {
push @lops3, $x;
}