/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1986-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* preprocessor library trace and debug support
*/
#include "pplib.h"
#include "ppfsm.h"
#include <ctype.h>
/*
* convert token string to printable form
*/
char*
pptokstr(register char* s, register int c)
{
register char* t;
if (t = s)
{
while (*t == ' ' || *t == '\t') t++;
c = *t ? *t : *s;
}
switch (c)
{
case 0:
case 0400:
return("`EOF'");
case ' ':
return("`space'");
case '\f':
return("`formfeed'");
case '\n':
return("`newline'");
case '\t':
return("`tab'");
case '\v':
return("`vertical-tab'");
case T_TOKCAT:
return("##");
default:
else if (s) return(s);
return(buf);
}
}
#if DEBUG & TRACE_debug
#include "ppdebug.h"
/*
* return input stream name given index
*/
char*
{
register int i;
for (i = 0; i < elementsof(ppinmap); i++)
{
switch (p->type)
{
case IN_MACRO:
#if MACDEF
case IN_MULTILINE:
#endif
if (p->symbol)
{
return(buf);
}
break;
}
}
return(buf);
}
/*
* return string given fsm lex state
*/
char*
{
register int i;
int splice;
lex &= 0x7f;
for (i = 0; i < (elementsof(pplexmap) - 1) && (lex > pplexmap[i].val || lex == pplexmap[i+1].val); i++);
{
if (pplexmap[i].val < 0) sfsprintf(buf, sizeof(buf), "%s|0x%04x%s", pplexmap[i].nam, lex, splice ? "|SPLICE" : "");
else sfsprintf(buf, sizeof(buf), "%s+%d", pplexmap[i-1].nam, lex - pplexmap[i-1].val, splice ? "|SPLICE" : "");
return(buf);
}
if (splice)
{
return(buf);
}
}
/*
* return string given map p of size n and flags
*/
static char*
{
register int i;
register int k;
register char* s;
s = buf;
for (i = 0; i < n; i++)
{
{
if (s > buf) *s++ = '|';
s += k;
}
}
*s = 0;
return(buf);
}
/*
* return string given pp.mode
*/
char*
{
}
/*
* return string given pp.option
*/
char*
{
}
/*
* return string given pp.state
*/
char*
{
}
#include <sig.h>
/*
* io stream stack trace
* sig==0 registers the handler
*/
void
{
register char* s;
register char* x;
register struct ppinstk* p;
static int handling;
if (!sig)
{
#ifdef SIGBUS
#endif
#ifdef SIGSEGV
#endif
#ifdef SIGILL
#endif
return;
}
if (handling)
{
pause();
}
{
{
x = s + 256;
while (*s && s < x)
{
}
}
}
handling = 0;
pause();
}
#endif