1 #include <stdio.h> 2 #include "awk.h" 3 #include "ytab.h" 4 5 static char *printname[94] = { 6 (char *) "FIRSTTOKEN", /* 258 */ 7 (char *) "PROGRAM", /* 259 */ 8 (char *) "PASTAT", /* 260 */ 9 (char *) "PASTAT2", /* 261 */ 10 (char *) "XBEGIN", /* 262 */ 11 (char *) "XEND", /* 263 */ 12 (char *) "NL", /* 264 */ 13 (char *) "ARRAY", /* 265 */ 14 (char *) "MATCH", /* 266 */ 15 (char *) "NOTMATCH", /* 267 */ 16 (char *) "MATCHOP", /* 268 */ 17 (char *) "FINAL", /* 269 */ 18 (char *) "DOT", /* 270 */ 19 (char *) "ALL", /* 271 */ 20 (char *) "CCL", /* 272 */ 21 (char *) "NCCL", /* 273 */ 22 (char *) "CHAR", /* 274 */ 23 (char *) "OR", /* 275 */ 24 (char *) "STAR", /* 276 */ 25 (char *) "QUEST", /* 277 */ 26 (char *) "PLUS", /* 278 */ 27 (char *) "EMPTYRE", /* 279 */ 28 (char *) "AND", /* 280 */ 29 (char *) "BOR", /* 281 */ 30 (char *) "APPEND", /* 282 */ 31 (char *) "EQ", /* 283 */ 32 (char *) "GE", /* 284 */ 33 (char *) "GT", /* 285 */ 34 (char *) "LE", /* 286 */ 35 (char *) "LT", /* 287 */ 36 (char *) "NE", /* 288 */ 37 (char *) "IN", /* 289 */ 38 (char *) "ARG", /* 290 */ 39 (char *) "BLTIN", /* 291 */ 40 (char *) "BREAK", /* 292 */ 41 (char *) "CLOSE", /* 293 */ 42 (char *) "CONTINUE", /* 294 */ 43 (char *) "DELETE", /* 295 */ 44 (char *) "DO", /* 296 */ 45 (char *) "EXIT", /* 297 */ 46 (char *) "FOR", /* 298 */ 47 (char *) "FUNC", /* 299 */ 48 (char *) "SUB", /* 300 */ 49 (char *) "GSUB", /* 301 */ 50 (char *) "IF", /* 302 */ 51 (char *) "INDEX", /* 303 */ 52 (char *) "LSUBSTR", /* 304 */ 53 (char *) "MATCHFCN", /* 305 */ 54 (char *) "NEXT", /* 306 */ 55 (char *) "NEXTFILE", /* 307 */ 56 (char *) "ADD", /* 308 */ 57 (char *) "MINUS", /* 309 */ 58 (char *) "MULT", /* 310 */ 59 (char *) "DIVIDE", /* 311 */ 60 (char *) "MOD", /* 312 */ 61 (char *) "ASSIGN", /* 313 */ 62 (char *) "ASGNOP", /* 314 */ 63 (char *) "ADDEQ", /* 315 */ 64 (char *) "SUBEQ", /* 316 */ 65 (char *) "MULTEQ", /* 317 */ 66 (char *) "DIVEQ", /* 318 */ 67 (char *) "MODEQ", /* 319 */ 68 (char *) "POWEQ", /* 320 */ 69 (char *) "PRINT", /* 321 */ 70 (char *) "PRINTF", /* 322 */ 71 (char *) "SPRINTF", /* 323 */ 72 (char *) "ELSE", /* 324 */ 73 (char *) "INTEST", /* 325 */ 74 (char *) "CONDEXPR", /* 326 */ 75 (char *) "POSTINCR", /* 327 */ 76 (char *) "PREINCR", /* 328 */ 77 (char *) "POSTDECR", /* 329 */ 78 (char *) "PREDECR", /* 330 */ 79 (char *) "VAR", /* 331 */ 80 (char *) "IVAR", /* 332 */ 81 (char *) "VARNF", /* 333 */ 82 (char *) "CALL", /* 334 */ 83 (char *) "NUMBER", /* 335 */ 84 (char *) "STRING", /* 336 */ 85 (char *) "REGEXPR", /* 337 */ 86 (char *) "GETLINE", /* 338 */ 87 (char *) "RETURN", /* 339 */ 88 (char *) "SPLIT", /* 340 */ 89 (char *) "SUBSTR", /* 341 */ 90 (char *) "WHILE", /* 342 */ 91 (char *) "CAT", /* 343 */ 92 (char *) "NOT", /* 344 */ 93 (char *) "UMINUS", /* 345 */ 94 (char *) "UPLUS", /* 346 */ 95 (char *) "POWER", /* 347 */ 96 (char *) "DECR", /* 348 */ 97 (char *) "INCR", /* 349 */ 98 (char *) "INDIRECT", /* 350 */ 99 (char *) "LASTTOKEN", /* 351 */ 100 }; 101 102 103 Cell *(*proctab[94])(Node **, int) = { 104 nullproc, /* FIRSTTOKEN */ 105 program, /* PROGRAM */ 106 pastat, /* PASTAT */ 107 dopa2, /* PASTAT2 */ 108 nullproc, /* XBEGIN */ 109 nullproc, /* XEND */ 110 nullproc, /* NL */ 111 array, /* ARRAY */ 112 matchop, /* MATCH */ 113 matchop, /* NOTMATCH */ 114 nullproc, /* MATCHOP */ 115 nullproc, /* FINAL */ 116 nullproc, /* DOT */ 117 nullproc, /* ALL */ 118 nullproc, /* CCL */ 119 nullproc, /* NCCL */ 120 nullproc, /* CHAR */ 121 nullproc, /* OR */ 122 nullproc, /* STAR */ 123 nullproc, /* QUEST */ 124 nullproc, /* PLUS */ 125 nullproc, /* EMPTYRE */ 126 boolop, /* AND */ 127 boolop, /* BOR */ 128 nullproc, /* APPEND */ 129 relop, /* EQ */ 130 relop, /* GE */ 131 relop, /* GT */ 132 relop, /* LE */ 133 relop, /* LT */ 134 relop, /* NE */ 135 instat, /* IN */ 136 arg, /* ARG */ 137 bltin, /* BLTIN */ 138 jump, /* BREAK */ 139 closefile, /* CLOSE */ 140 jump, /* CONTINUE */ 141 awkdelete, /* DELETE */ 142 dostat, /* DO */ 143 jump, /* EXIT */ 144 forstat, /* FOR */ 145 nullproc, /* FUNC */ 146 sub, /* SUB */ 147 gsub, /* GSUB */ 148 ifstat, /* IF */ 149 sindex, /* INDEX */ 150 nullproc, /* LSUBSTR */ 151 matchop, /* MATCHFCN */ 152 jump, /* NEXT */ 153 jump, /* NEXTFILE */ 154 arith, /* ADD */ 155 arith, /* MINUS */ 156 arith, /* MULT */ 157 arith, /* DIVIDE */ 158 arith, /* MOD */ 159 assign, /* ASSIGN */ 160 nullproc, /* ASGNOP */ 161 assign, /* ADDEQ */ 162 assign, /* SUBEQ */ 163 assign, /* MULTEQ */ 164 assign, /* DIVEQ */ 165 assign, /* MODEQ */ 166 assign, /* POWEQ */ 167 printstat, /* PRINT */ 168 awkprintf, /* PRINTF */ 169 awksprintf, /* SPRINTF */ 170 nullproc, /* ELSE */ 171 intest, /* INTEST */ 172 condexpr, /* CONDEXPR */ 173 incrdecr, /* POSTINCR */ 174 incrdecr, /* PREINCR */ 175 incrdecr, /* POSTDECR */ 176 incrdecr, /* PREDECR */ 177 nullproc, /* VAR */ 178 nullproc, /* IVAR */ 179 getnf, /* VARNF */ 180 call, /* CALL */ 181 nullproc, /* NUMBER */ 182 nullproc, /* STRING */ 183 nullproc, /* REGEXPR */ 184 awkgetline, /* GETLINE */ 185 jump, /* RETURN */ 186 split, /* SPLIT */ 187 substr, /* SUBSTR */ 188 whilestat, /* WHILE */ 189 cat, /* CAT */ 190 boolop, /* NOT */ 191 arith, /* UMINUS */ 192 arith, /* UPLUS */ 193 arith, /* POWER */ 194 nullproc, /* DECR */ 195 nullproc, /* INCR */ 196 indirect, /* INDIRECT */ 197 nullproc, /* LASTTOKEN */ 198 }; 199 200 char *tokname(int n) 201 { 202 static char buf[100]; 203 204 if (n < FIRSTTOKEN || n > LASTTOKEN) { 205 sprintf(buf, "token %d", n); 206 return buf; 207 } 208 return printname[n-FIRSTTOKEN]; 209 } 210