// return: 1 if escaped (forced to be symbol) static int read_token(char c, int digits) { int i=0, ch, escaped=0, issym=0, first=1; while (1) { if (!first) { ch = ios_getc(F); if (ch == IOS_EOF) goto terminate; c = (char)ch; } first = 0; if (c == '|') { issym = 1; escaped = !escaped; } else if (c == '\\') { issym = 1; ch = ios_getc(F); if (ch == IOS_EOF) goto terminate; accumchar((char)ch, &i); } else if (!escaped && !(symchar(c) && (!digits || isdigit(c)))) { break; } else { accumchar(c, &i); } } ios_ungetc(c, F); terminate: buf[i++] = '\0'; return issym; }
// return: 1 for dot token, 0 for symbol static int read_token(FILE *f, char c) { int i=0, ch, escaped=0, dot=(c=='.'), totread=0; ungetc(c, f); while (1) { ch = fgetc(f); totread++; if (ch == EOF) goto terminate; c = (char)ch; if (c == '|') { escaped = !escaped; } else if (c == '\\') { ch = fgetc(f); if (ch == EOF) goto terminate; accumchar((char)ch, &i); } else if (!escaped && !symchar(c)) { break; } else { accumchar(c, &i); } } ungetc(c, f); terminate: buf[i++] = '\0'; return (dot && (totread==2)); }