extern int match
[], symclass
[], action
[], newstate
[];
{int i
,j
,found
,current
, someread
;
someread
= 0; /* indicates haven't read part of a routine */
endbuf
= getline(&endline
, &endchar
, &endcom
, & comchar
);
if (progress
&& endbuf
!= -1) fprintf(stderr
,"parsing\n");
while(endbuf
!= -1) /* getline returns -1 when no more input */
for (i
= begline
; i
<= endline
; i
++)
if (!(i
% progress
)) fprintf(stderr
,"parsing line %d\n",i
);
for (i
= 0; i
< endbuf
; i
++)
if ( (current
< 0 || current
>= snum
) && current
!= ABORT
)
strerr("in parsing:","","");
fprintf(stderr
,"line %d of file, parser in invalid state", begline
,current
);
fprintf(stderr
,"treating it as straight line code\n");
for (j
= match
[current
]; j
< match
[current
+ 1]; j
++)
if ((symclass
[j
] == 0 && c
== symbol
[j
]) ||
(symclass
[j
] != 0 && classmatch(c
,symclass
[j
]) ))
error("in syntax:","","");
fprintf(stderr
,"between lines %d and %d of file\n",begline
, endline
);
fprintf(stderr
,"symbol '%c' does not match entries for state %d\n",c
,current
);
fprintf(stderr
,"treating it as straight line code\n");
current
= act(action
[j
],c
,i
);
if (current
== nulls
) current
= newstate
[j
];
if (current
== ABORT
) break;
endbuf
= getline(&endline
, &endchar
, &endcom
,&comchar
);
hashtab
= challoc(sizeof(*hashtab
) * maxhash
);
chain
= challoc(sizeof(*chain
) * maxhash
);
value
= challoc(sizeof(*value
) * maxhash
);
for (i
= 0; i
< maxhash
; i
++)
for (i
= 0; i
< maxhash
; ++i
)
if (value
[i
] == -2 && hashtab
[i
] != -1L)
error("in syntax; label used but does not appear as statement label:","","");
fprintf(stderr
,"%D\n",hashtab
[i
]);
chfree(hashtab
,sizeof(*hashtab
) * maxhash
);
chfree(chain
,sizeof(*chain
) * maxhash
);
chfree(value
,sizeof(*value
) * maxhash
);
int quo
, rem
, hcount
, temp
;
rem
= x
- (quo
* maxhash
);
for (hcount
=0; (hashtab
[temp
] != -1L) && (hashtab
[temp
] != x
) && (hcount
<maxhash
); hcount
++)
temp
= (temp
+ quo
)%maxhash
;
if(hcount
>=maxhash
) faterr("hash table overflow - too many labels","","");
addref(x
,ptr
) /* put ptr in chain for x or assign value of x to *ptr */
{ /* x already assigned value */
int *temp1
, *temp2
, index
, temp0
;
{ /* trace chain of linked labels */
error("in syntax: ","","");
fprintf(stderr
,"attempt to redefine value of label %D between lines %d and %d\n",
temp1
= &chain
[index
]; /* trace chain for each label */
fixvalue(y
, chain
[index
]);
{ /* attach implicit chain to x chain */
temp2
= index
; /* attach y linked labels to x linked labels */
while (value
[temp2
] >= 0)
value
[temp2
] = value
[hash(y
)];
if (y
== implicit
) clear(y
);