1 5cedca1b 2004-05-15 devnull %Start A str def sc br thru sh
10 5cedca1b 2004-05-15 devnull #undef input
11 5cedca1b 2004-05-15 devnull #undef unput
12 5cedca1b 2004-05-15 devnull /* #include <stdio.h> lex puts one out for us */
13 5cedca1b 2004-05-15 devnull #include <ctype.h>
14 5cedca1b 2004-05-15 devnull #include <stdlib.h>
15 5cedca1b 2004-05-15 devnull #include "pic.h"
16 5cedca1b 2004-05-15 devnull #include "y.tab.h"
18 5cedca1b 2004-05-15 devnull extern char *filename;
19 5cedca1b 2004-05-15 devnull extern struct symtab symtab[];
21 5cedca1b 2004-05-15 devnull void pbstr(char *);
22 5cedca1b 2004-05-15 devnull void dodef(struct symtab *stp);
23 5cedca1b 2004-05-15 devnull void undefine(char *s);
24 5cedca1b 2004-05-15 devnull void shell_init(void), shell_exec(void), shell_text(char *);
25 5cedca1b 2004-05-15 devnull void endfor(void);
27 5cedca1b 2004-05-15 devnull int yyback(int *, int);
28 5cedca1b 2004-05-15 devnull int yylook(void);
29 5cedca1b 2004-05-15 devnull int yywrap(void);
31 5cedca1b 2004-05-15 devnull #define CADD cbuf[clen++]=yytext[0]; \
32 5cedca1b 2004-05-15 devnull if (clen>=CBUFLEN-1) { ERROR "string too long", cbuf WARNING; BEGIN A; }
33 5cedca1b 2004-05-15 devnull #define CBUFLEN 500
34 5cedca1b 2004-05-15 devnull char cbuf[CBUFLEN];
35 5cedca1b 2004-05-15 devnull int c, clen, cflag, delim;
36 5cedca1b 2004-05-15 devnull int ifsw = 0; /* 1 if if statement in progress */
39 5cedca1b 2004-05-15 devnull A [a-zA-Z_]
40 5cedca1b 2004-05-15 devnull B [a-zA-Z0-9_]
45 5cedca1b 2004-05-15 devnull switch (yybgin-yysvec-1) { /* witchcraft */
51 5cedca1b 2004-05-15 devnull return('}');
54 5cedca1b 2004-05-15 devnull return(']');
57 5cedca1b 2004-05-15 devnull <A>{WS} ;
58 5cedca1b 2004-05-15 devnull <A>"\\"\n ;
59 5cedca1b 2004-05-15 devnull <A>\n { return(ST); }
60 5cedca1b 2004-05-15 devnull <A>";" { return(ST); }
61 5cedca1b 2004-05-15 devnull <A>"}" { BEGIN sc; return(ST); }
62 5cedca1b 2004-05-15 devnull <A>"]" { BEGIN br; return(ST); }
63 5cedca1b 2004-05-15 devnull <A>"{"{WS}*(#.*)?\n+ { return(yylval.i = yytext[0]); }
65 5cedca1b 2004-05-15 devnull <A>^".PS".* { if (curfile == infile) ERROR ".PS found inside .PS/.PE" WARNING; }
66 5cedca1b 2004-05-15 devnull <A>^".PE".* { if (curfile == infile) {
67 5cedca1b 2004-05-15 devnull yylval.p = PEstring = tostring(yytext);
68 5cedca1b 2004-05-15 devnull return(EOF);
71 5cedca1b 2004-05-15 devnull <A>^".".* { yylval.p = tostring(yytext); return(TROFF); }
73 5cedca1b 2004-05-15 devnull <A>print return(yylval.i = PRINT);
74 5cedca1b 2004-05-15 devnull <A>box return(yylval.i = BOX);
75 5cedca1b 2004-05-15 devnull <A>circle return(yylval.i = CIRCLE);
76 5cedca1b 2004-05-15 devnull <A>arc return(yylval.i = ARC);
77 5cedca1b 2004-05-15 devnull <A>ellipse return(yylval.i = ELLIPSE);
78 5cedca1b 2004-05-15 devnull <A>arrow return(yylval.i = ARROW);
79 5cedca1b 2004-05-15 devnull <A>spline return(yylval.i = SPLINE);
80 5cedca1b 2004-05-15 devnull <A>line return(yylval.i = LINE);
81 5cedca1b 2004-05-15 devnull <A>move return(yylval.i = MOVE);
82 5cedca1b 2004-05-15 devnull <A>"[]" return(yylval.i = BLOCK);
83 5cedca1b 2004-05-15 devnull <A>reset return(RESET);
84 5cedca1b 2004-05-15 devnull <A>sprintf return(SPRINTF);
86 5cedca1b 2004-05-15 devnull <A>same return(SAME);
87 5cedca1b 2004-05-15 devnull <A>between return(BETWEEN);
88 5cedca1b 2004-05-15 devnull <A>and return(AND);
94 5cedca1b 2004-05-15 devnull <A>"."(e|east) { yylval.i = EAST; return(CORNER); }
95 5cedca1b 2004-05-15 devnull <A>"."(r|right) { yylval.i = EAST; return(CORNER); }
96 5cedca1b 2004-05-15 devnull <A>"."(w|west) { yylval.i = WEST; return(CORNER); }
97 5cedca1b 2004-05-15 devnull <A>"."(l|left) { yylval.i = WEST; return(CORNER); }
98 5cedca1b 2004-05-15 devnull <A>"."(n|north) { yylval.i = NORTH; return(CORNER); }
99 5cedca1b 2004-05-15 devnull <A>"."(t|top) { yylval.i = NORTH; return(CORNER); }
100 5cedca1b 2004-05-15 devnull <A>"."(s|south) { yylval.i = SOUTH; return(CORNER); }
101 5cedca1b 2004-05-15 devnull <A>"."(b|bot|bottom) { yylval.i = SOUTH; return(CORNER); }
102 5cedca1b 2004-05-15 devnull <A>"."(c|center) { yylval.i = CENTER; return(CORNER); }
103 5cedca1b 2004-05-15 devnull <A>".start" { yylval.i = START; return(CORNER); }
104 5cedca1b 2004-05-15 devnull <A>".end" { yylval.i = END; return(CORNER); }
105 5cedca1b 2004-05-15 devnull <A>".ne" { yylval.i = NE; return(CORNER); }
106 5cedca1b 2004-05-15 devnull <A>".se" { yylval.i = SE; return(CORNER); }
107 5cedca1b 2004-05-15 devnull <A>".nw" { yylval.i = NW; return(CORNER); }
108 5cedca1b 2004-05-15 devnull <A>".sw" { yylval.i = SW; return(CORNER); }
110 5cedca1b 2004-05-15 devnull <A>top" "+of { yylval.i = NORTH; return(CORNER); }
111 5cedca1b 2004-05-15 devnull <A>north" "+of { yylval.i = NORTH; return(CORNER); }
112 5cedca1b 2004-05-15 devnull <A>bottom" "+of { yylval.i = SOUTH; return(CORNER); }
113 5cedca1b 2004-05-15 devnull <A>south" "+of { yylval.i = SOUTH; return(CORNER); }
114 5cedca1b 2004-05-15 devnull <A>left" "+of { yylval.i = WEST; return(CORNER); }
115 5cedca1b 2004-05-15 devnull <A>west" "+of { yylval.i = WEST; return(CORNER); }
116 5cedca1b 2004-05-15 devnull <A>right" "+of { yylval.i = EAST; return(CORNER); }
117 5cedca1b 2004-05-15 devnull <A>east" "+of { yylval.i = EAST; return(CORNER); }
118 5cedca1b 2004-05-15 devnull <A>center" "+of { yylval.i = CENTER; return(CORNER); }
119 5cedca1b 2004-05-15 devnull <A>start" "+of { yylval.i = START; return(CORNER); }
120 5cedca1b 2004-05-15 devnull <A>end" "+of { yylval.i = END; return(CORNER); }
122 5cedca1b 2004-05-15 devnull <A>height|ht { yylval.i = HEIGHT; return(ATTR); }
123 5cedca1b 2004-05-15 devnull <A>width|wid { yylval.i = WIDTH; return(ATTR); }
124 5cedca1b 2004-05-15 devnull <A>radius|rad { yylval.i = RADIUS; return(ATTR); }
125 5cedca1b 2004-05-15 devnull <A>diameter|diam { yylval.i = DIAMETER; return(ATTR); }
126 5cedca1b 2004-05-15 devnull <A>size { yylval.i = SIZE; return(ATTR); }
127 5cedca1b 2004-05-15 devnull <A>left { yylval.i = LEFT; return(DIR); }
128 5cedca1b 2004-05-15 devnull <A>right { yylval.i = RIGHT; return(DIR); }
129 5cedca1b 2004-05-15 devnull <A>up { yylval.i = UP; return(DIR); }
130 5cedca1b 2004-05-15 devnull <A>down { yylval.i = DOWN; return(DIR); }
131 5cedca1b 2004-05-15 devnull <A>cw { yylval.i = CW; return(ATTR); }
132 5cedca1b 2004-05-15 devnull <A>clockwise { yylval.i = CW; return(ATTR); }
133 5cedca1b 2004-05-15 devnull <A>ccw { yylval.i = CCW; return(ATTR); }
134 5cedca1b 2004-05-15 devnull <A>invis(ible)? { yylval.i = INVIS; return(ATTR); }
135 5cedca1b 2004-05-15 devnull <A>noedge { yylval.i = INVIS; return ATTR; }
136 5f1cf8e6 2004-05-16 devnull <A>fill { yylval.i = FILL; return ATTR; }
137 5cedca1b 2004-05-15 devnull <A>solid ;
138 5cedca1b 2004-05-15 devnull <A>dot(ted)? return(yylval.i = DOT);
139 5cedca1b 2004-05-15 devnull <A>dash(ed)? return(yylval.i = DASH);
140 5cedca1b 2004-05-15 devnull <A>chop return(yylval.i = CHOP);
142 5cedca1b 2004-05-15 devnull <A>spread { yylval.i = SPREAD; return TEXTATTR; }
143 5cedca1b 2004-05-15 devnull <A>ljust { yylval.i = LJUST; return TEXTATTR; }
144 5cedca1b 2004-05-15 devnull <A>rjust { yylval.i = RJUST; return TEXTATTR; }
145 5cedca1b 2004-05-15 devnull <A>above { yylval.i = ABOVE; return TEXTATTR; }
146 5cedca1b 2004-05-15 devnull <A>below { yylval.i = BELOW; return TEXTATTR; }
147 5cedca1b 2004-05-15 devnull <A>center { yylval.i = CENTER; return TEXTATTR; }
149 5cedca1b 2004-05-15 devnull <A>"<-" { yylval.i = HEAD1; return(HEAD); }
150 5cedca1b 2004-05-15 devnull <A>"->" { yylval.i = HEAD2; return(HEAD); }
151 5cedca1b 2004-05-15 devnull <A>"<->" { yylval.i = HEAD12; return(HEAD); }
153 5cedca1b 2004-05-15 devnull <A>".x" return(yylval.i = DOTX);
154 5cedca1b 2004-05-15 devnull <A>".y" return(yylval.i = DOTY);
155 5cedca1b 2004-05-15 devnull <A>"."(ht|height) return(yylval.i = DOTHT);
156 5cedca1b 2004-05-15 devnull <A>"."(wid|width) return(yylval.i = DOTWID);
157 5cedca1b 2004-05-15 devnull <A>"."(rad|radius) return(yylval.i = DOTRAD);
159 5cedca1b 2004-05-15 devnull <A>from return(yylval.i = FROM);
160 5cedca1b 2004-05-15 devnull <A>to return(yylval.i = TO);
161 5cedca1b 2004-05-15 devnull <A>at return(yylval.i = AT);
162 5cedca1b 2004-05-15 devnull <A>by return(yylval.i = BY);
163 5cedca1b 2004-05-15 devnull <A>with return(yylval.i = WITH);
164 5cedca1b 2004-05-15 devnull <A>last return(yylval.i = LAST);
166 5cedca1b 2004-05-15 devnull <A>log return(LOG);
167 5cedca1b 2004-05-15 devnull <A>exp return(EXP);
168 5cedca1b 2004-05-15 devnull <A>sin return(SIN);
169 5cedca1b 2004-05-15 devnull <A>cos return(COS);
170 5cedca1b 2004-05-15 devnull <A>atan2 return(ATAN2);
171 5cedca1b 2004-05-15 devnull <A>sqrt return(SQRT);
172 5cedca1b 2004-05-15 devnull <A>rand return(RAND);
173 5cedca1b 2004-05-15 devnull <A>max return(MAX);
174 5cedca1b 2004-05-15 devnull <A>min return(MIN);
175 5cedca1b 2004-05-15 devnull <A>int return(INT);
177 5cedca1b 2004-05-15 devnull <A>"==" return(EQ);
178 5cedca1b 2004-05-15 devnull <A>">=" return(GE);
179 5cedca1b 2004-05-15 devnull <A>"<=" return(LE);
180 5cedca1b 2004-05-15 devnull <A>"!=" return(NEQ);
181 5cedca1b 2004-05-15 devnull <A>">" return(GT);
182 5cedca1b 2004-05-15 devnull <A>"<" return(LT);
183 5cedca1b 2004-05-15 devnull <A>"&&" return(ANDAND);
184 5cedca1b 2004-05-15 devnull <A>"||" return(OROR);
185 5cedca1b 2004-05-15 devnull <A>"!" return(NOT);
187 5cedca1b 2004-05-15 devnull <A>Here return(yylval.i = HERE);
189 5cedca1b 2004-05-15 devnull <A>for return(FOR);
190 5cedca1b 2004-05-15 devnull <A>^Endfor\n { endfor(); }
191 5cedca1b 2004-05-15 devnull <A>do { yylval.p = delimstr("loop body"); return(DOSTR); }
193 5cedca1b 2004-05-15 devnull <A>copy|include return(COPY);
194 5cedca1b 2004-05-15 devnull <A>(thru|through){WS}+ { BEGIN thru; return(THRU); }
195 5cedca1b 2004-05-15 devnull <thru>{A}{B}*|. { yylval.st = copythru(yytext); BEGIN A; return(DEFNAME); }
196 5cedca1b 2004-05-15 devnull <A>until return(UNTIL);
198 5cedca1b 2004-05-15 devnull <A>if { ifsw = 1; return(IF); }
199 5cedca1b 2004-05-15 devnull <A>then { if (!ifsw) { yylval.i = THEN; return(ATTR); }
200 5cedca1b 2004-05-15 devnull yylval.p = delimstr("then part"); ifsw = 0;
201 5cedca1b 2004-05-15 devnull return(THENSTR); }
202 5cedca1b 2004-05-15 devnull <A>else { yylval.p = delimstr("else part"); return(ELSESTR); }
204 5cedca1b 2004-05-15 devnull <A>sh{WS}+ { BEGIN sh;
205 5cedca1b 2004-05-15 devnull if ((delim = input()) == '{') delim = '}'; /* no nested {} */
206 5cedca1b 2004-05-15 devnull shell_init(); }
207 5cedca1b 2004-05-15 devnull <sh>{A}{B}* { struct symtab *p;
208 5cedca1b 2004-05-15 devnull if (yytext[0] == delim) {
209 5cedca1b 2004-05-15 devnull shell_exec();
210 5cedca1b 2004-05-15 devnull BEGIN A;
211 5cedca1b 2004-05-15 devnull } else {
212 5cedca1b 2004-05-15 devnull p = lookup(yytext);
213 5cedca1b 2004-05-15 devnull if (p != NULL && p->s_type == DEFNAME) {
214 5cedca1b 2004-05-15 devnull c = input();
215 5cedca1b 2004-05-15 devnull unput(c);
216 5cedca1b 2004-05-15 devnull if (c == '(')
217 5cedca1b 2004-05-15 devnull dodef(p);
219 5cedca1b 2004-05-15 devnull pbstr(p->s_val.p);
221 5cedca1b 2004-05-15 devnull shell_text(yytext);
224 5cedca1b 2004-05-15 devnull <sh>.|\n { if (yytext[0] == delim) {
225 5cedca1b 2004-05-15 devnull shell_exec();
226 5cedca1b 2004-05-15 devnull BEGIN A;
228 5cedca1b 2004-05-15 devnull shell_text(yytext);
231 5cedca1b 2004-05-15 devnull <A>define{WS}+ { BEGIN def; }
232 5cedca1b 2004-05-15 devnull <def>{A}{B}* { definition(yytext); BEGIN A; }
233 5cedca1b 2004-05-15 devnull <A>undef(ine)?{WS}+{A}{B}* { undefine(yytext); }
235 5cedca1b 2004-05-15 devnull <A>first { yylval.i = 1; return(NTH); }
236 5cedca1b 2004-05-15 devnull <A>{D}+(th|nd|rd|st) { yylval.i = atoi(yytext); return(NTH); }
237 5cedca1b 2004-05-15 devnull <A>({D}+("."?){D}*|"."{D}+)((e|E)("+"|-)?{D}+)?i? {
238 5cedca1b 2004-05-15 devnull yylval.f = atof(yytext); return(NUMBER); }
240 5cedca1b 2004-05-15 devnull <A>{A}{B}* { struct symtab *p;
241 5cedca1b 2004-05-15 devnull p = lookup(yytext);
242 5cedca1b 2004-05-15 devnull if (p != NULL && p->s_type == DEFNAME) {
243 5cedca1b 2004-05-15 devnull c = input();
244 5cedca1b 2004-05-15 devnull unput(c);
245 5cedca1b 2004-05-15 devnull if (c == '(') /* it's name(...) */
246 5cedca1b 2004-05-15 devnull dodef(p);
247 5cedca1b 2004-05-15 devnull else { /* no argument list */
248 5cedca1b 2004-05-15 devnull pbstr(p->s_val.p);
249 5cedca1b 2004-05-15 devnull dprintf("pushing back `%s'\n", p->s_val.p);
251 5cedca1b 2004-05-15 devnull } else if (islower(yytext[0])) {
252 5cedca1b 2004-05-15 devnull yylval.p = tostring(yytext);
253 5cedca1b 2004-05-15 devnull return(VARNAME);
254 5cedca1b 2004-05-15 devnull } else {
255 5cedca1b 2004-05-15 devnull yylval.p = tostring(yytext);
256 5cedca1b 2004-05-15 devnull return(PLACENAME);
260 5cedca1b 2004-05-15 devnull <A>\" { BEGIN str; clen=0; }
261 5cedca1b 2004-05-15 devnull <str>\" { cbuf[clen]=0; yylval.p = tostring(cbuf); BEGIN A; return(TEXT); }
262 5cedca1b 2004-05-15 devnull <str>\n { cbuf[clen]=0; ERROR "missing quote in string \"%s\"", cbuf WARNING;
263 5cedca1b 2004-05-15 devnull BEGIN A; return(ST); }
264 5cedca1b 2004-05-15 devnull <str>"\\\"" { cbuf[clen++]='"'; }
265 5cedca1b 2004-05-15 devnull <str>"\\"t { cbuf[clen++]='\t'; }
266 5cedca1b 2004-05-15 devnull <str>"\\\\" { cbuf[clen++]='\\'; }
267 5cedca1b 2004-05-15 devnull <str>. { CADD; }
269 5cedca1b 2004-05-15 devnull <A>#.* ;
271 5cedca1b 2004-05-15 devnull <A>. return(yylval.i = yytext[0]);