IF
y WHILE
requieren un tipo entero
en la condición de control:
pl@nereida:~/doc/casiano/PLBOOK/PLBOOK/code/Simple-Types/lib/Simple$ \ sed -ne '/^control/,189p' Trans.trg | cat -n 1 control: /IF|IFELSE|WHILE/:con($bool) 2 => { 3 $bool = char2int($con, 0); 4 5 type_error("Condition must have integer type!", $bool->line) 6 unless $bool->{t} == $INT; 7 8 $con->{t} = $VOID; 9 10 return 1; 11 }
Veamos un ejemplo de uso:
l@nereida:~/Lbook/code/Simple-Types/script$ usetypes.pl prueba19.c 2 1 int c[20][30], d; 2 3 int f(int a, int b) { 4 if (c[2]) 5 return 6 (a+b)*d*c[1][1]; 7 } Type Error at line 4: Condition must have integer type! pl@nereida:~/Lbook/code/Simple-Types/script$