extern int cntlines;
#endif
-static int eofseen;
extern char options[];
STATIC
}
}
for (;;) {
- if (class(ch) == STNL) {
+ if (!(ch & 0200) && class(ch) == STNL) {
LineNumber++;
#ifdef DEBUG
cntlines++;
}
else if (ch == EOI) {
lexerror("unterminated comment");
+ PushBack();
break;
}
LoadChar(ch);
len = ISTRSIZE;
str->s_str = p = Malloc((unsigned int) ISTRSIZE);
while (LoadChar(ch), ch != upto) {
- if (class(ch) == STNL) {
+ if (!(ch & 0200) && class(ch) == STNL) {
lexerror("newline in string");
LineNumber++;
#ifdef DEBUG
{
register int ch;
- for (;;) {
- LoadChar(ch);
- if ((ch & 0200) && ch != EOI) {
- error("non-ascii '\\%03o' read", ch & 0377);
- continue;
- }
- break;
- }
- if (ch == EOI) {
- eofseen = 1;
- return '\n';
+ while (LoadChar(ch), (ch & 0200) && ch != EOI) {
+ error("non-ascii '\\%03o' read", ch & 0377);
}
return ch;
}
{
register int ch = getch();
register int i = 0;
- char buf[IDFSIZE + 2];
+ char buf[IDFSIZE];
register char *c = buf;
* Do not skip newlines
*/
ch = getch();
- if (class(ch) == STNL) {
+ if (class(ch) == STNL || class(ch) == STEOI) {
LineNumber++;
error(s_error);
return;
i = i*10 + (ch - '0');
ch = getch();
}
- while (ch != '"' && class(ch) != STNL) ch = getch();
+ while (ch != '"' && class(ch) != STNL && class(ch) != STEOI)
+ ch = getch();
if (ch == '"') {
c = buf;
do {
- *c++ = ch = getch();
- if (class(ch) == STNL) {
+ ch = getch();
+ if (c < &buf[IDFSIZE]) *c++ = ch;
+ if (class(ch) == STNL || class(ch) == STEOI) {
LineNumber++;
error(s_error);
return;
*--c = '\0';
do {
ch = getch();
- } while (class(ch) != STNL);
+ } while (class(ch) != STNL && class(ch) != STEOI);
/*
* Remember the file name
*/
- if (!eofseen && strcmp(FileName,buf)) {
+ if (class(ch) == STNL && strcmp(FileName,buf)) {
FileName = Salloc(buf,(unsigned) strlen(buf) + 1);
}
}
- if (eofseen) {
+ if (class(ch) == STEOI) {
error(s_error);
return;
}
LineNumber = i;
}
-static
-UnloadChar(ch)
-{
- if (ch == EOI) eofseen = 1;
- else PushBack();
-}
-
int
LLlex()
{
return tk->tk_symb;
}
-again1:
- if (eofseen) {
- eofseen = 0;
- ch = EOI;
- }
- else {
again:
- LoadChar(ch);
- if ((ch & 0200) && ch != EOI) {
- error("non-ascii '\\%03o' read", ch & 0377);
- goto again;
- }
- }
-
+ ch = getch();
tk->tk_lineno = LineNumber;
switch (class(ch)) {
cntlines++;
#endif
CheckForLineDirective();
- goto again1;
+ goto again;
case STSKIP:
goto again;
SkipComment();
goto again;
}
- UnloadChar(nch);
+ PushBack();
}
if (ch == '&') return tk->tk_symb = AND;
if (ch == '~') return tk->tk_symb = NOT;
default :
crash("(LLlex, STCOMP)");
}
- UnloadChar(nch);
+ PushBack();
return tk->tk_symb = ch;
case STIDF:
}
} while(in_idf(ch));
- UnloadChar(ch);
+ PushBack();
*tag = '\0';
if (*(tag - 1) == '_') {
lexerror("last character of an identifier may not be an underscore");
else {
state = End;
if (ch == 'H') base = 16;
- else UnloadChar(ch);
+ else PushBack();
}
break;
state = End;
if (ch != 'H') {
lexerror("H expected after hex number");
- UnloadChar(ch);
+ PushBack();
}
break;
state = Hex;
break;
}
- UnloadChar(ch);
+ PushBack();
ch = *--np;
*np++ = '\0';
/* Fall through */
LoadChar(ch);
if (!(ch == '+' || ch == '-' || is_dig(ch)))
goto noscale;
- UnloadChar(ch);
+ PushBack();
}
if (np < &buf[NUMSIZE]) *np++ = 'E';
LoadChar(ch);
noscale:
*np++ = '\0';
- UnloadChar(ch);
+ PushBack();
if (np >= &buf[NUMSIZE]) {
tk->TOK_REL = Salloc("0.0", 5);
$(CC) $(LDFLAGS) $(OBJ) $(OLIBS) -o $(CURRDIR)main
-size $(CURRDIR)main
-$(CURRDIR)omain: $(OBJ) $(CURRDIR)Makefile
- $(CC) $(LDFLAGS) $(OBJ) $(OLIBS) -o $(CURRDIR)omain
- size $(CURRDIR)omain
+$(CURRDIR)omain: $(OBJ) #$(CURRDIR)Makefile
+ #$(CC) $(LDFLAGS) $(OBJ) $(OLIBS) -o $(CURRDIR)omain
+ #size $(CURRDIR)omain
-$(CURRDIR)cemain: $(OBJ) $(CURRDIR)Makefile
- $(CC) $(LDFLAGS) $(OBJ) $(OLIBS) -o $(CURRDIR)cemain
- size $(CURRDIR)cemain
+$(CURRDIR)cemain: $(OBJ) #$(CURRDIR)Makefile
+ #$(CC) $(LDFLAGS) $(OBJ) $(OLIBS) -o $(CURRDIR)cemain
+ #size $(CURRDIR)cemain
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
) {
switch(df->df_kind) {
case D_INUSE:
- if (kind != D_INUSE) {
+ if (kind != D_INUSE && kind != D_ERROR) {
error("identifier \"%s\" already used; may not be redefined in this scope", df->df_idf->id_text);
+ df->df_kind = D_ERROR;
+ break;
}
return df;
break;
case D_FORWTYPE:
if (kind & (D_FORWTYPE|D_TYPE)) return df;
- else {
- error("identifier \"%s\" must be a type",
- id->id_text);
- }
- return df;
-
+ error("identifier \"%s\" must be a type", id->id_text);
+ df->df_kind = D_ERROR;
+ break;
case D_FORWARD:
/* A forward reference, for which we may now have
found a definition.
if (! (kind & (D_FORWARD | D_FORWMODULE))) {
FreeNode(df->for_node);
}
-
- /* Fall through */
-
- case D_ERROR:
- /* A definition generated by the compiler, because
- it found an error. Maybe, the user gives a
- definition after all.
- */
- if (kind & (D_TYPE|D_PROCEDURE|D_CONST)) {
- df->df_flags = D_DEFINED;
- }
- df->df_kind = kind;
- return df;
+ df->df_kind = D_ERROR; /* avoiding error message */
+ break;
}
- if (kind != D_ERROR) {
+ if (kind != D_ERROR && df->df_kind != D_ERROR) {
/* Avoid spurious error messages
*/
error("identifier \"%s\" already declared",
id->id_text);
}
+ if (df->df_scope == scope || df->df_kind == D_ERROR) {
+ df->df_kind = kind;
+ if (kind & (D_TYPE|D_PROCEDURE|D_CONST)) {
+ df->df_flags = D_DEFINED;
+ }
- return df;
+ return df;
+ }
}
return MkDef(id, scope, kind);