|
|
Bugzilla Link |
927 |
Created on |
Mar 04, 2012 08:09 |
Resolution |
INVALID |
Resolved on |
Apr 21, 2012 19:06 |
Version |
1.00beta |
OS |
Linux |
Architecture |
PC |
Extended Description
The following program generates weird parsing errors,
which are totally wrong:
sac2c -check tb -v 1 -g -o testpnm testpnm.sac
ERROR: line 28 file: testpnm.sac
ERROR: Unique var f__SSA0_2 of type File referenced more than once
ERROR: line 36 file: testpnm.sac
ERROR: Previous reference was here
*** Compilation failed ***
*** Exit code 66 (Checking uniqueness property of objects)
*** 2 Error(s), 0 Warning(s)
use StdIO: { printf, fopen, fclose, File, fgetc, fscanf };
use RuntimeError: { error };
use CommandLine: { argc, argv };
use SysErr: { fail };
import String: { string, == };
import ScalarArith: all;
void skip(File f)
{
}
int, int, int, int parse(string name)
{
int kind, widths, height, maxval;
File f;
e, f = fopen(name, "rb");
if (fail(e)) {
error( (:int) e, "Could not open %s for reading", name);
}
kind = 0;
widths = 0;
height = 0;
maxval = 0;
if (fgetc(f) == 'P') {
T = fgetc(f);
if (T >= '1' && T <= '6') {
kind = toi(T) - toi('0');
skip(f);
n, widths = fscanf(f, " %u");
if (n == 1) {
skip(f);
n, height = fscanf(f, " %u");
}
if (kind == 1 || kind == 4) {
maxval = 1;
}
else if (n == 1) {
skip(f);
// n, maxval = fscanf(f, " %u");
}
if (n == 1) {
skip(f);
}
}
}
fclose(f);
return (kind, widths, height, maxval);
}
int main()
{
if (argc() < 2) {
error(1, "Need at least one arg");
}
for (i = 1; i < argc(); ++i) {
s = argv(i);
kind, widths, height, maxval = parse(s);
}
return 0;
}