fort not included in "all" or "install" until f77 copy of sources
[unix-history] / usr / src / old / awk / awk.def
CommitLineData
c48090b0 1/* awk.def 4.2 83/02/09 */
7949e46e
KM
2
3#define hack int
4#define AWKFLOAT float
5#define xfree(a) { if(a!=NULL) { yfree(a); a=NULL;} }
c48090b0 6#define strfree(a) { if(a!=NULL && a!=EMPTY) { yfree(a);} a=EMPTY; }
7949e46e
KM
7#define yfree free
8#ifdef DEBUG
9# define dprintf if(dbg)printf
10#else
11# define dprintf(x1, x2, x3, x4)
12#endif
13typedef AWKFLOAT awkfloat;
14
15extern char **FS;
16extern char **RS;
17extern char **ORS;
18extern char **OFS;
19extern char **OFMT;
20extern awkfloat *NR;
21extern awkfloat *NF;
22extern char **FILENAME;
23
24extern char record[];
c48090b0 25extern char EMPTY[];
7949e46e
KM
26extern int dbg;
27extern int lineno;
28extern int errorflag;
29extern int donefld; /* 1 if record broken into fields */
30extern int donerec; /* 1 if record is valid (no fld has changed */
31
32typedef struct val { /* general value during processing */
33 char *nval; /* name, for variables only */
34 char *sval; /* string value */
35 awkfloat fval; /* value as number */
36 unsigned tval; /* type info */
37 struct val *nextval; /* ptr to next if chained */
38} cell;
39extern cell *symtab[];
40cell *setsymtab(), *lookup(), **makesymtab();
41
42extern cell *recloc; /* location of input record */
43extern cell *nrloc; /* NR */
44extern cell *nfloc; /* NF */
45
46#define STR 01 /* string value is valid */
47#define NUM 02 /* number value is valid */
48#define FLD 04 /* FLD means don't free string space */
49#define CON 010 /* this is a constant */
50#define ARR 020 /* this is an array */
51
52awkfloat setfval(), getfval();
53char *setsval(), *getsval();
54char *tostring(), *tokname(), *malloc();
55double log(), sqrt(), exp(), atof();
56
57/* function types */
58#define FLENGTH 1
59#define FSQRT 2
60#define FEXP 3
61#define FLOG 4
62#define FINT 5
63
64typedef struct {
65 char otype;
66 char osub;
67 cell *optr;
68} obj;
69
70#define BOTCH 1
71struct nd {
72 char ntype;
73 char subtype;
74 struct nd *nnext;
75 int nobj;
76 struct nd *narg[BOTCH]; /* C won't take a zero length array */
77};
78typedef struct nd node;
79extern node *winner;
80extern node *nullstat;
81
82/* otypes */
83#define OCELL 0
84#define OEXPR 1
85#define OBOOL 2
86#define OJUMP 3
87
88/* cell subtypes */
89#define CTEMP 4
90#define CNAME 3
91#define CVAR 2
92#define CFLD 1
93#define CCON 0
94
95/* bool subtypes */
96#define BTRUE 1
97#define BFALSE 2
98
99/* jump subtypes */
100#define JEXIT 1
101#define JNEXT 2
102#define JBREAK 3
103#define JCONT 4
104
105/* node types */
106#define NVALUE 1
107#define NSTAT 2
108#define NEXPR 3
109#define NPA2 4
110
111extern obj (*proctab[])();
112extern obj true, false;
113extern int pairstack[], paircnt;
114
115#define cantexec(n) (n->ntype == NVALUE)
116#define notlegal(n) (n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN]== nullproc)
117#define isexpr(n) (n->ntype == NEXPR)
118#define isjump(n) (n.otype == OJUMP)
119#define isexit(n) (n.otype == OJUMP && n.osub == JEXIT)
120#define isbreak(n) (n.otype == OJUMP && n.osub == JBREAK)
121#define iscont(n) (n.otype == OJUMP && n.osub == JCONT)
122#define isnext(n) (n.otype == OJUMP && n.osub == JNEXT)
123#define isstr(n) (n.optr->tval & STR)
124#define istrue(n) (n.otype == OBOOL && n.osub == BTRUE)
125#define istemp(n) (n.otype == OCELL && n.osub == CTEMP)
c48090b0
SL
126#define isfld(n) (!donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval==EMPTY)
127#define isrec(n) (donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval!=EMPTY)
7949e46e
KM
128obj nullproc();
129obj relop();
130
131#define MAXSYM 50
132#define HAT 0177 /* matches ^ in regular expr */
133 /* watch out for mach dep */