/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1986-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* miscellaneous preprocessor support
*/
#include "pplib.h"
/*
* macro symbol def|ref
*/
struct ppsymbol*
{
if (!(sym = ppsymget(pp.symtab, name)) && (ref <= REF_NORMAL && pp.macref || ref == REF_CREATE || ref == REF_DELETE && (pp.mode & (INIT|READONLY))))
{
}
{
if (pp.macref) (*pp.macref)(sym, error_info.file, error_info.line, ref == REF_NORMAL && (pp.state & CONDITIONAL) ? REF_IF : ref, 0L);
}
#if COMPATIBLE
#endif
if (ref == REF_IF && sym && (sym->flags & SYM_PREDEFINED) && *name != '_' && !(pp.mode & (HOSTED|INACTIVE)))
{
{
return(0);
}
}
return(sym);
}
/*
* common predicate assertion operations
* op is DEFINE or UNDEF
*/
void
{
register struct pplist* a;
register struct pplist* p;
register struct pplist* q;
{
case DEFINE:
goto mark;
case UNDEF:
a = 0;
goto unmark;
}
{
p = 0;
q = a;
while (q)
{
{
q = q->next;
if (p) p->next = q;
else a = q;
}
else
{
p = q;
q = q->next;
}
}
{
return;
}
}
{
p->next = a;
mark:
}
}
/*
* parse a predicate argument list
* the args are placed in pp.args
* forms:
*
* predicate <identifier> type=T_ID
* predicate ( <identifier> ) type=T_ID
* predicate ( ) type=0
* predicate ( <balanced-paren-list> ) type=T_STRING
* otherwise type=<other>
*/
int
pppredargs(void)
{
register int c;
register int n;
register int type;
char* pptoken;
{
case '(':
type = 0;
n = 1;
c = pplex();
for (;;)
{
switch (c)
{
case '(':
n++;
break;
case '\n':
ungetchr(c);
type = 0;
goto done;
case ')':
if (!--n) goto done;
break;
}
if (c != ' ')
{
}
c = pplex();
}
done:
break;
case '\n':
ungetchr('\n');
type = 0;
break;
}
return(type);
}
/*
* sync output line number
*/
int
ppsync(void)
{
long m;
{
{
}
{
{
if (error_info.line)
}
else
{
while (m-- > 0)
ppputchar('\n');
}
}
else
{
ppputchar('\n');
}
}
return 0;
}