/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-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 *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* code for tree nodes and name walking
*
* David Korn
* AT&T Labs
*
*/
#include "defs.h"
#include "name.h"
#include "argnod.h"
#include "lexstates.h"
struct nvdir
{
int len;
};
{
char *cp;
int c;
if(n>=0)
return(-1);
return(c);
}
{
{
{
return(np);
}
}
}
return(fp);
{
}
return(dp);
}
{
0,
0,
0,
,0,0,0,
};
{
register char *cp;
register int c;
if(*str=='.')
str++;
{
if(c=='[')
{
}
if(c=='.')
return(cp);
}
return(0);
}
{
return(0);
{
return(fp);
}
return(0);
}
{
if(!dp)
return(0);
len -= 1;
#if 1
while(1)
{
sh.last_table = 0;
break;
break;
*next = 0;
*next = '.';
break;
}
#else
sh.last_table = 0;
#endif
if(*name)
{
{
else
{
last = 0;
}
}
else
}
else
while(1)
{
if(!last)
next = 0;
{
c = *next;
*next = 0;
}
if(!np)
{
{
{
}
}
else
}
if(next)
*next = c;
{
return(0);
if(nv_istable(np))
else
if(nfp)
{
}
else
}
else
break;
break;
np = 0;
}
return((void*)dp);
}
{
return(0);
}
{
register char *cp;
while(1)
{
{
#if 0
char *sptr;
#endif
if(nv_isarray(np))
continue;
#if 0
{
}
#endif
#if 0
#endif
{
}
{
if((nfp=nextdisc(np)) && (nfp->disc->getval||nfp->disc->getnum) && nv_isvtree(np) && strcmp(cp,dp->data))
nfp = 0;
{
if(nv_istable(np))
else
/* check for recursive walk */
{
break;
}
if(save)
return(cp);
return(0);
{
#if 0
#endif
}
else
}
return(cp);
}
}
break;
}
return(0);
}
{
}
{
char *type=0;
{
{
break;
}
}
type = "-T";
else if(!prefix)
type = "type";
if(type)
{
cp++;
else
}
}
/*
* print the attributes of name value pair give by <np>
*/
{
register char *cp;
char *ip=0;
{
break;
}
{
{
if(nv_isvtree(np))
else if((!np->nvalue.cp||np->nvalue.cp==Empty) && nv_isattr(np,~NV_NOFREE)==NV_MINIMAL && strcmp(np->nvname,"_"))
}
return;
}
{
attr &= ~NV_NOPRINT;
return;
if(fp)
{
if(typep)
{
cp++;
else
fp = 0;
}
}
{
break;
/*
* the following test is needed to prevent variables
* with E attribute from being given the F
* attribute as well
*/
continue;
if(val&NV_INTEGER)
{
{
char **xp=0;
{
continue;
}
continue;
{
}
}
if(prefix)
{
if(ip)
{
ip = 0;
}
}
else
}
{
{
cp = "precision";
else
cp = "base";
if(!prefix)
}
break;
}
}
if(fp)
if(noname)
return;
}
}
struct Walk
{
int noscope;
int indent;
int nofollow;
int array;
int flags;
};
{
if(ap)
{
if(indent>=0)
{
tabs=1;
}
{
associative=1;
}
}
while(1)
{
{
if(!nv_nextsub(np))
break;
continue;
}
if(tabs)
tabs=0;
if(associative||special)
{
break;
}
{
if(indent>0)
goto skip;
}
ep = 0;
xp = 0;
{
xp++;
*xp = 0;
else
xp = 0;
}
fmtq = "";
{
{
}
}
c = '\n';
if(indent<0)
{
c = ';';
if(ap)
}
if(xp)
*xp = ' ';
skip:
if(!more)
return;
}
}
{
return;
if(*name=='.')
{
return;
{
nv_local = 1;
fp = 0;
}
if(fp)
return;
if(nv_isarray(np))
return;
}
{
{
return;
}
{
break;
}
if(!xp)
return;
}
return;
{
isarray=1;
isarray=2;
else
}
{
#if 0
#endif
return;
}
{
return;
}
isarray = 2;
if(!special)
{
if(*name!='.')
if((np->nvalue.cp && np->nvalue.cp!=Empty) || nv_isattr(np,~(NV_MINIMAL|NV_NOFREE)) || nv_isvtree(np))
{
}
if(isarray==2)
return;
}
{
{
}
else
}
}
/*
* format initialization list given a list of assignments <argp>
*/
{
register int m,r,l;
if(n==0)
else
m++;
{
{
}
}
{
continue;
if(n && cp[m-1]==0)
break;
{
cp +=m;
r = 0;
if(*cp=='.')
cp++,r++;
{
if(outfile)
{
*nextcp = 0;
{
*nextcp = '.';
continue;
}
{
char *sp;
sp++;
else
}
*nextcp = '.';
}
else
{
continue;
}
if(*argv)
continue;
break;
}
else if(outfile && !wp->nofollow && argv[1] && memcmp(arg,argv[1],l=strlen(arg))==0 && argv[1][l]=='[')
{
int k=1;
if(!np)
continue;
k = array_elem(ap);
if(!k)
{
continue;
}
}
{
}
else
{
{
else
}
}
}
else
break;
}
if(outfile)
{
int c = prefix[m-1];
if(c=='.')
cp[m-1] = 0;
if(c=='.')
cp[m-1] = c;
}
return(--argv);
}
/*
* walk the virtual tree and print or delete name-value pairs
*/
{
char *subscript=0;
void *dir;
if(xp)
{
}
if(shp->last_table)
{
stakputc('[');
stakputc(']');
stakputc('.');
}
if(subscript)
{
continue;
if(xp)
{
continue;
stakseek(0);
stakputc(0);
{
}
continue;
}
n++;
}
if(xp)
{
return((char*)0);
}
argv += n;
*argv = 0;
if(flags&1)
outfile = 0;
else
if(!outfile)
return((char*)0);
}
{
if(np)
return(0);
}
/*
* get discipline for compound initializations
*/
{
{
}
return("()");
}
/*
* put discipline for compound initializations
*/
{
int nleft = 0;
return;
{
{
return;
}
}
return;
if(nleft==0)
{
}
}
/*
* Insert discipline to cause $x to print current tree
*/
{
return;
}