1989-02-07 11:04:05 +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".
|
|
|
|
*/
|
|
|
|
/* $Header$ */
|
|
|
|
/* PREPROCESSOR: INPUT SKIP FUNCTIONS */
|
|
|
|
|
|
|
|
#include "nopp.h"
|
|
|
|
#include "arith.h"
|
|
|
|
#include "LLlex.h"
|
|
|
|
#include "class.h"
|
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
#ifndef NOPP
|
1989-09-19 16:13:23 +00:00
|
|
|
extern int InputLevel;
|
|
|
|
|
1989-02-07 11:04:05 +00:00
|
|
|
int
|
|
|
|
skipspaces(ch, skipnl)
|
|
|
|
register int ch;
|
|
|
|
{
|
|
|
|
/* skipspaces() skips any white space and returns the first
|
|
|
|
non-space character.
|
|
|
|
*/
|
1989-09-19 16:13:23 +00:00
|
|
|
register int nlseen = 0;
|
|
|
|
|
1989-02-07 11:04:05 +00:00
|
|
|
for (;;) {
|
|
|
|
while (class(ch) == STSKIP)
|
|
|
|
ch = GetChar();
|
|
|
|
if (skipnl && class(ch) == STNL) {
|
|
|
|
ch = GetChar();
|
1989-09-19 16:13:23 +00:00
|
|
|
LineNumber++;
|
|
|
|
nlseen++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (ch == TOKSEP && InputLevel) {
|
|
|
|
ch = GetChar();
|
1989-02-07 11:04:05 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* \\\n are handled by trigraph */
|
|
|
|
|
|
|
|
if (ch == '/') {
|
|
|
|
ch = GetChar();
|
1989-09-19 16:13:23 +00:00
|
|
|
if (ch == '*' && !InputLevel) {
|
1989-02-07 11:04:05 +00:00
|
|
|
skipcomment();
|
|
|
|
ch = GetChar();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UnGetChar();
|
|
|
|
return '/';
|
|
|
|
}
|
|
|
|
}
|
1989-09-29 16:20:38 +00:00
|
|
|
else if (nlseen && ch == '#') {
|
1989-09-19 16:13:23 +00:00
|
|
|
domacro();
|
|
|
|
ch = GetChar();
|
|
|
|
} else
|
1989-02-07 11:04:05 +00:00
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif NOPP
|
|
|
|
|
1989-10-18 13:12:31 +00:00
|
|
|
SkipToNewLine()
|
1989-02-07 11:04:05 +00:00
|
|
|
{
|
|
|
|
register int ch;
|
1989-10-18 13:12:31 +00:00
|
|
|
register int garbage = 0;
|
1989-12-12 12:52:03 +00:00
|
|
|
#ifndef NOPP
|
|
|
|
register int delim = 0;
|
|
|
|
#endif
|
1989-02-07 11:04:05 +00:00
|
|
|
|
|
|
|
while ((ch = GetChar()) != '\n') {
|
1989-11-22 13:58:36 +00:00
|
|
|
#ifndef NOPP
|
1989-12-12 12:52:03 +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 == '/') {
|
1989-10-12 14:22:35 +00:00
|
|
|
if ((ch = GetChar()) == '*'
|
|
|
|
&& !InputLevel
|
|
|
|
) {
|
1989-02-07 11:04:05 +00:00
|
|
|
skipcomment();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
1989-11-22 13:58:36 +00:00
|
|
|
#endif
|
1989-10-18 13:12:31 +00:00
|
|
|
if (!is_wsp(ch))
|
|
|
|
garbage = 1;
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|
1989-12-12 12:52:03 +00:00
|
|
|
#ifndef NOPP
|
|
|
|
if (delim) strict("unclosed opening %c", delim);
|
|
|
|
#endif
|
1989-02-07 11:04:05 +00:00
|
|
|
++LineNumber;
|
1989-10-18 13:12:31 +00:00
|
|
|
return garbage;
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|