1 #ifndef PI 2 #define PI 3.1415926535897932384626433832795028841971693993751 3 #endif 4 5 #define MAXWID 8.5 /* default limits max picture to 8.5 x 11; */ 6 #define MAXHT 11 /* change to taste without peril */ 7 8 #define dprintf if(dbg)printf 9 10 extern void yyerror(char *); 11 12 extern char errbuf[1000]; 13 14 #undef sprintf /* Snow Leopard */ 15 16 #define ERROR sprintf(errbuf, 17 #define FATAL ), yyerror(errbuf), exit(1) 18 #define WARNING ), yyerror(errbuf) 19 20 #define DEFAULT 0 21 22 #define HEAD1 1 23 #define HEAD2 2 24 #define HEAD12 (HEAD1+HEAD2) 25 #define INVIS 4 26 #define CW_ARC 8 /* clockwise arc */ 27 #define DOTBIT 16 /* line styles */ 28 #define DASHBIT 32 29 #define FILLBIT 64 /* gray-fill on boxes, etc. */ 30 #define NOEDGEBIT 128 /* no edge on filled object */ 31 32 #define CENTER 01 /* text attributes */ 33 #define LJUST 02 34 #define RJUST 04 35 #define ABOVE 010 36 #define BELOW 020 37 #define SPREAD 040 38 39 #define SCALE 1.0 /* default scale: units/inch */ 40 #define WID 0.75 /* default width for boxes and ellipses */ 41 #define WID2 0.375 42 #define HT 0.5 /* default height and line length */ 43 #define HT2 (HT/2) 44 #define HT5 (HT/5) 45 #define HT10 (HT/10) 46 47 /* these have to be like so, so that we can write */ 48 /* things like R & V, etc. */ 49 #define H 0 50 #define V 1 51 #define R_DIR 0 52 #define U_DIR 1 53 #define L_DIR 2 54 #define D_DIR 3 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) 61 62 typedef float ofloat; /* for o_val[] in obj; could be double */ 63 64 typedef struct obj { /* stores various things in variable length */ 65 int o_type; 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" */ 70 float o_y; 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!!!! */ 81 } obj; 82 83 typedef union { /* the yacc stack type */ 84 int i; 85 char *p; 86 obj *o; 87 double f; 88 struct symtab *st; 89 } YYSTYPE; 90 91 extern YYSTYPE yylval, yyval; 92 93 struct symtab { 94 char *s_name; 95 int s_type; 96 YYSTYPE s_val; 97 struct symtab *s_next; 98 }; 99 100 typedef struct { /* attribute of an object */ 101 int a_type; 102 int a_sub; 103 YYSTYPE a_val; 104 } Attr; 105 106 typedef struct { 107 int t_type; /* CENTER, LJUST, etc. */ 108 char t_op; /* optional sign for size changes */ 109 char t_size; /* size, abs or rel */ 110 char *t_val; 111 } Text; 112 113 #define String 01 114 #define Macro 02 115 #define File 04 116 #define Char 010 117 #define Thru 020 118 #define Free 040 119 120 typedef struct { /* input source */ 121 int type; /* Macro, String, File */ 122 char *sp; /* if String or Macro */ 123 } Src; 124 125 extern Src src[], *srcp; /* input source stack */ 126 127 typedef struct { 128 FILE *fin; 129 char *fname; 130 int lineno; 131 } Infile; 132 133 extern Infile infile[], *curfile; 134 135 #define MAXARGS 20 136 typedef struct { /* argument stack */ 137 char *argstk[MAXARGS]; /* pointers to args */ 138 char *argval; /* points to space containing args */ 139 } Arg; 140 141 extern int dbg; 142 extern obj **objlist; 143 extern int nobj, nobjlist; 144 extern Attr *attr; 145 extern int nattr, nattrlist; 146 extern Text *text; 147 extern int ntextlist; 148 extern int ntext; 149 extern int ntext1; 150 extern double curx, cury; 151 extern int hvmode; 152 extern int codegen; 153 extern char *PEstring; 154 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); 163 void resetvar(void); 164 void checkscale(char *); 165 void pushsrc(int, char *); 166 void copy(void); 167 void copyuntil(char *); 168 void copyfile(char *); 169 void copydef(struct symtab *); 170 void definition(char *); 171 struct symtab *copythru(char *); 172 int input(void); 173 int unput(int); 174 void extreme(double, double); 175 176 extern double deltx, delty; 177 extern int lineno; 178 extern int synerr; 179 180 extern double xmin, ymin, xmax, ymax; 181 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); 202 void addtattr(int); 203 void printlf(int, char *); 204 205 struct pushstack { 206 double p_x; 207 double p_y; 208 int p_hvmode; 209 double p_xmin; 210 double p_ymin; 211 double p_xmax; 212 double p_ymax; 213 struct symtab *p_symtab; 214 }; 215 extern struct pushstack stack[]; 216 extern int nstack; 217 extern int cw; 218 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") 223