1989-10-23 10:35:56 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1989-10-23 10:35:56 +00:00
|
|
|
/* PREPROCESSOR: INPUT SKIP FUNCTIONS */
|
|
|
|
|
|
|
|
#include "arith.h"
|
|
|
|
#include "LLlex.h"
|
|
|
|
#include "class.h"
|
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
extern int InputLevel;
|
|
|
|
|
|
|
|
int
|
|
|
|
skipspaces(ch, skipnl)
|
|
|
|
register int ch;
|
|
|
|
{
|
|
|
|
/* skipspaces() skips any white space and returns the first
|
|
|
|
non-space character.
|
|
|
|
*/
|
|
|
|
register int nlseen = 0;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
while (class(ch) == STSKIP)
|
|
|
|
ch = GetChar();
|
|
|
|
if (skipnl && class(ch) == STNL) {
|
|
|
|
ch = GetChar();
|
|
|
|
LineNumber++;
|
|
|
|
nlseen++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (ch == TOKSEP && InputLevel) {
|
|
|
|
ch = GetChar();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* \\\n are handled by trigraph */
|
|
|
|
|
|
|
|
if (ch == '/') {
|
|
|
|
ch = GetChar();
|
|
|
|
if (ch == '*' && !InputLevel) {
|
|
|
|
skipcomment();
|
|
|
|
ch = GetChar();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UnGetChar();
|
|
|
|
return '/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nlseen && ch == '#') {
|
|
|
|
domacro();
|
|
|
|
ch = GetChar();
|
|
|
|
} else
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1989-11-22 12:59:15 +00:00
|
|
|
SkipToNewLine()
|
1989-10-23 10:35:56 +00:00
|
|
|
{
|
|
|
|
register int ch;
|
1989-11-22 12:59:15 +00:00
|
|
|
register int garbage = 0;
|
1989-12-12 12:41:39 +00:00
|
|
|
register int delim = 0;
|
1989-10-23 10:35:56 +00:00
|
|
|
|
|
|
|
while ((ch = GetChar()) != '\n') {
|
1989-12-12 12:41:39 +00:00
|
|
|
if (delim) {
|
|
|
|
if (ch == '\\') {
|
|
|
|
if (GetChar() == '\n') break;
|
|
|
|
} else if (ch == delim) {
|
|
|
|
delim = 0;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
} else if (ch == '\'' || ch == '\"') {
|
|
|
|
delim = ch;
|
|
|
|
garbage = 1;
|
|
|
|
} else if (ch == '/') {
|
1994-10-28 15:26:36 +00:00
|
|
|
if (GetChar() == '*' && !InputLevel) {
|
1989-10-23 10:35:56 +00:00
|
|
|
skipcomment();
|
|
|
|
continue;
|
|
|
|
}
|
1994-10-28 15:26:36 +00:00
|
|
|
else UnGetChar();
|
1989-10-23 10:35:56 +00:00
|
|
|
}
|
1991-01-15 11:51:40 +00:00
|
|
|
else if (ch == TOKSEP && InputLevel) {
|
|
|
|
continue;
|
|
|
|
}
|
1989-11-22 12:59:15 +00:00
|
|
|
if (!is_wsp(ch))
|
|
|
|
garbage = 1;
|
1989-10-23 10:35:56 +00:00
|
|
|
}
|
1989-12-12 12:41:39 +00:00
|
|
|
if (delim) strict("unclosed opening %c", delim);
|
1989-10-23 10:35:56 +00:00
|
|
|
++LineNumber;
|
1989-11-22 12:59:15 +00:00
|
|
|
return garbage;
|
1989-10-23 10:35:56 +00:00
|
|
|
}
|