2 #define PI 3.1415926535897932384626433832795028841971693993751
5 #define MAXWID 8.5 /* default limits max picture to 8.5 x 11; */
6 #define MAXHT 11 /* change to taste without peril */
8 #define dprintf if(dbg)printf
10 extern void yyerror(char *);
12 extern char errbuf[200];
14 #undef sprintf /* Snow Leopard */
16 #define ERROR sprintf(errbuf,
17 #define FATAL ), yyerror(errbuf), exit(1)
18 #define WARNING ), yyerror(errbuf)
24 #define HEAD12 (HEAD1+HEAD2)
26 #define CW_ARC 8 /* clockwise arc */
27 #define DOTBIT 16 /* line styles */
29 #define FILLBIT 64 /* gray-fill on boxes, etc. */
30 #define NOEDGEBIT 128 /* no edge on filled object */
32 #define CENTER 01 /* text attributes */
39 #define SCALE 1.0 /* default scale: units/inch */
40 #define WID 0.75 /* default width for boxes and ellipses */
42 #define HT 0.5 /* default height and line length */
47 /* these have to be like so, so that we can write */
48 /* things like R & V, etc. */
55 #define ishor(n) (((n) & V) == 0)
56 #define isvert(n) (((n) & V) != 0)
57 #define isright(n) ((n) == R_DIR)
58 #define isleft(n) ((n) == L_DIR)
59 #define isdown(n) ((n) == D_DIR)
60 #define isup(n) ((n) == U_DIR)
62 typedef float ofloat; /* for o_val[] in obj; could be double */
64 typedef struct obj { /* stores various things in variable length */
66 int o_count; /* number of things */
67 int o_nobj; /* index in objlist */
68 int o_mode; /* hor or vert */
69 float o_x; /* coord of "center" */
71 int o_nt1; /* 1st index in text[] for this object */
72 int o_nt2; /* 2nd; difference is #text strings */
73 int o_attr; /* HEAD, CW, INVIS, etc., go here */
74 int o_size; /* linesize */
75 int o_nhead; /* arrowhead style */
76 struct symtab *o_symtab; /* symtab for [...] */
77 float o_ddval; /* value of dot/dash expression */
78 float o_fillval; /* gray scale value */
79 ofloat o_val[1]; /* actually this will be > 1 in general */
80 /* type is not always FLOAT!!!! */
83 typedef union { /* the yacc stack type */
91 extern YYSTYPE yylval, yyval;
97 struct symtab *s_next;
100 typedef struct { /* attribute of an object */
107 int t_type; /* CENTER, LJUST, etc. */
108 char t_op; /* optional sign for size changes */
109 char t_size; /* size, abs or rel */
120 typedef struct { /* input source */
121 int type; /* Macro, String, File */
122 char *sp; /* if String or Macro */
125 extern Src src[], *srcp; /* input source stack */
133 extern Infile infile[], *curfile;
136 typedef struct { /* argument stack */
137 char *argstk[MAXARGS]; /* pointers to args */
138 char *argval; /* points to space containing args */
142 extern obj **objlist;
143 extern int nobj, nobjlist;
145 extern int nattr, nattrlist;
147 extern int ntextlist;
150 extern double curx, cury;
153 extern char *PEstring;
155 char *tostring(char *);
156 char *grow(char *, char *, int, int);
157 double getfval(char *), getcomp(obj *, int), getblkvar(obj *, char *);
158 YYSTYPE getvar(char *);
159 struct symtab *lookup(char *), *makevar(char *, int, YYSTYPE);
160 char *ifstat(double, char *, char *), *delimstr(char *), *sprintgen(char *);
161 void forloop(char *var, double from, double to, int op, double by, char *_str);
162 int setdir(int), curdir(void);
164 void checkscale(char *);
165 void pushsrc(int, char *);
167 void copyuntil(char *);
168 void copyfile(char *);
169 void copydef(struct symtab *);
170 void definition(char *);
171 struct symtab *copythru(char *);
174 void extreme(double, double);
176 extern double deltx, delty;
180 extern double xmin, ymin, xmax, ymax;
182 obj *leftthing(int), *boxgen(void), *circgen(int), *arcgen(int);
183 obj *linegen(int), *splinegen(void), *movegen(void);
184 obj *textgen(void), *plotgen(void);
185 obj *troffgen(char *), *rightthing(obj *, int), *blockgen(obj *, obj *);
186 obj *makenode(int, int), *makepos(double, double);
187 obj *fixpos(obj *, double, double);
188 obj *addpos(obj *, obj *), *subpos(obj *, obj *);
189 obj *makebetween(double, obj *, obj *);
190 obj *getpos(obj *, int), *gethere(void), *getfirst(int, int);
191 obj *getlast(int, int), *getblock(obj *, char *);
192 void savetext(int, char *);
193 void makeiattr(int, int);
194 void makevattr(char *);
195 void makefattr(int type, int sub, double f);
196 void maketattr(int, char *);
197 void makeoattr(int, obj *);
198 void makeattr(int type, int sub, YYSTYPE val);
199 void printexpr(double);
200 void printpos(obj *);
201 void exprsave(double);
203 void printlf(int, char *);
213 struct symtab *p_symtab;
215 extern struct pushstack stack[];
219 extern double errcheck(double, char *);
220 #define Log10(x) errcheck(log10(x), "log")
221 #define Exp(x) errcheck(exp(x), "exp")
222 #define Sqrt(x) errcheck(sqrt(x), "sqrt")