1987-03-10 17:51:10 +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$ */
|
1986-03-10 13:07:55 +00:00
|
|
|
/* PREPROCESSOR: INPUT SKIP FUNCTIONS */
|
|
|
|
|
|
|
|
#include "nopp.h"
|
|
|
|
#include "arith.h"
|
|
|
|
#include "LLlex.h"
|
|
|
|
#include "class.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "interface.h"
|
|
|
|
|
|
|
|
#ifndef NOPP
|
1993-11-16 11:49:17 +00:00
|
|
|
int
|
1988-07-29 18:38:25 +00:00
|
|
|
skipspaces(ch, skipnl)
|
1986-03-10 13:07:55 +00:00
|
|
|
register int ch;
|
|
|
|
{
|
|
|
|
/* skipspaces() skips any white space and returns the first
|
|
|
|
non-space character.
|
|
|
|
*/
|
1989-08-21 10:58:24 +00:00
|
|
|
register int nlseen = 0;
|
|
|
|
|
1986-03-10 13:07:55 +00:00
|
|
|
for (;;) {
|
1989-08-21 10:58:24 +00:00
|
|
|
while (class(ch) == STSKIP) {
|
|
|
|
nlseen = 0;
|
1986-03-10 13:07:55 +00:00
|
|
|
LoadChar(ch);
|
1989-08-21 10:58:24 +00:00
|
|
|
}
|
1988-07-29 19:22:48 +00:00
|
|
|
if (skipnl && class(ch) == STNL) {
|
|
|
|
LoadChar(ch);
|
1989-08-21 10:58:24 +00:00
|
|
|
LineNumber++;
|
|
|
|
nlseen++;
|
1988-07-29 19:22:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
1986-03-10 13:07:55 +00:00
|
|
|
/* How about "\\\n"????????? */
|
|
|
|
|
|
|
|
if (ch == '/') {
|
|
|
|
LoadChar(ch);
|
|
|
|
if (ch == '*') {
|
|
|
|
skipcomment();
|
|
|
|
LoadChar(ch);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PushBack();
|
|
|
|
return '/';
|
|
|
|
}
|
|
|
|
}
|
1989-08-21 10:58:24 +00:00
|
|
|
else if (nlseen && ch == '#') {
|
|
|
|
domacro();
|
|
|
|
LoadChar(ch);
|
|
|
|
/* ch is the first character of a line. This means
|
|
|
|
* that nlseen will still be true.
|
|
|
|
*/
|
|
|
|
} else
|
1986-03-10 13:07:55 +00:00
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
}
|
1991-12-17 14:11:15 +00:00
|
|
|
#endif /* NOPP */
|
1986-03-10 13:07:55 +00:00
|
|
|
|
|
|
|
skipline()
|
|
|
|
{
|
|
|
|
/* skipline() skips all characters until a newline character
|
|
|
|
is seen, not escaped by a '\\'.
|
|
|
|
Any comment is skipped.
|
|
|
|
*/
|
|
|
|
register int c;
|
|
|
|
|
|
|
|
LoadChar(c);
|
|
|
|
while (class(c) != STNL && c != EOI) {
|
1993-11-15 09:25:32 +00:00
|
|
|
if (class(c) == STSTR || class(c) == STCHAR) {
|
|
|
|
register int stopc = c;
|
|
|
|
int escaped;
|
|
|
|
do {
|
|
|
|
escaped = 0;
|
|
|
|
LoadChar(c);
|
|
|
|
if (class(c) == STNL || c == EOI) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (c == '\\') {
|
|
|
|
LoadChar(c);
|
|
|
|
if (c == '\n') {
|
|
|
|
++LineNumber;
|
|
|
|
}
|
|
|
|
else escaped = 1;
|
|
|
|
}
|
|
|
|
} while (escaped || c != stopc);
|
|
|
|
if (class(c) != STNL && c != EOI) {
|
|
|
|
LoadChar(c);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
1986-03-10 13:07:55 +00:00
|
|
|
if (c == '\\') {
|
|
|
|
LoadChar(c);
|
|
|
|
if (class(c) == STNL)
|
|
|
|
++LineNumber;
|
|
|
|
}
|
|
|
|
if (c == '/') {
|
|
|
|
LoadChar(c);
|
|
|
|
if (c == '*')
|
|
|
|
skipcomment();
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
LoadChar(c);
|
|
|
|
}
|
|
|
|
++LineNumber;
|
|
|
|
|
|
|
|
if (c == EOI) { /* garbage input... */
|
|
|
|
lexerror("unexpected EOF while skipping text");
|
|
|
|
PushBack();
|
|
|
|
}
|
|
|
|
}
|