1: #ifndef lint
   2: static char sccsid[] = "@(#)proc.c	4.3 8/11/83";
   3: #endif
   4: 
   5: #include "awk.h"
   6: #define NULL 0
   7: struct xx
   8: {   int token;
   9:     char *name;
  10:     char *pname;
  11: } proc[] = {
  12:     { PROGRAM, "program", NULL},
  13:     { BOR, "boolop", " || "},
  14:     { AND, "boolop", " && "},
  15:     { NOT, "boolop", " !"},
  16:     { NE, "relop", " != "},
  17:     { EQ, "relop", " == "},
  18:     { LE, "relop", " <= "},
  19:     { LT, "relop", " < "},
  20:     { GE, "relop", " >= "},
  21:     { GT, "relop", " > "},
  22:     { ARRAY, "array", NULL},
  23:     { INDIRECT, "indirect", "$("},
  24:     { SUBSTR, "substr", "substr"},
  25:     { INDEX, "sindex", "sindex"},
  26:     { SPRINTF, "asprintf", "sprintf "},
  27:     { ADD, "arith", " + "},
  28:     { MINUS, "arith", " - "},
  29:     { MULT, "arith", " * "},
  30:     { DIVIDE, "arith", " / "},
  31:     { MOD, "arith", " % "},
  32:     { UMINUS, "arith", " -"},
  33:     { PREINCR, "incrdecr", "++"},
  34:     { POSTINCR, "incrdecr", "++"},
  35:     { PREDECR, "incrdecr", "--"},
  36:     { POSTDECR, "incrdecr", "--"},
  37:     { CAT, "cat", " "},
  38:     { PASTAT, "pastat", NULL},
  39:     { PASTAT2, "dopa2", NULL},
  40:     { MATCH, "matchop", " ~ "},
  41:     { NOTMATCH, "matchop", " !~ "},
  42:     { PRINTF, "aprintf", "printf"},
  43:     { PRINT, "print", "print"},
  44:     { SPLIT, "split", "split"},
  45:     { ASSIGN, "assign", " = "},
  46:     { ADDEQ, "assign", " += "},
  47:     { SUBEQ, "assign", " -= "},
  48:     { MULTEQ, "assign", " *= "},
  49:     { DIVEQ, "assign", " /= "},
  50:     { MODEQ, "assign", " %= "},
  51:     { IF, "ifstat", "if("},
  52:     { WHILE, "whilestat", "while("},
  53:     { FOR, "forstat", "for("},
  54:     { IN, "instat", "instat"},
  55:     { NEXT, "jump", "next"},
  56:     { EXIT, "jump", "exit"},
  57:     { BREAK, "jump", "break"},
  58:     { CONTINUE, "jump", "continue"},
  59:     { FNCN, "fncn", "fncn"},
  60:     { GETLINE, "getline", "getline"},
  61:     { 0, ""},
  62: };
  63: #define SIZE    LASTTOKEN - FIRSTTOKEN
  64: char *table[SIZE];
  65: char *names[SIZE];
  66: main()
  67: {   struct xx *p;
  68:     int i;
  69:     printf("#include \"awk.def\"\n");
  70:     printf("obj nullproc();\n");
  71:     for(p=proc;p->token!=0;p++)
  72:         if(p==proc || strcmp(p->name, (p-1)->name))
  73:             printf("extern obj %s();\n",p->name);
  74:     for(p=proc;p->token!=0;p++)
  75:         table[p->token-FIRSTTOKEN]=p->name;
  76:     printf("obj (*proctab[%d])() = {\n", SIZE);
  77:     for(i=0;i<SIZE;i++)
  78:         if(table[i]==0) printf("/*%s*/\tnullproc,\n",tokname(i+FIRSTTOKEN));
  79:         else printf("/*%s*/\t%s,\n",tokname(i+FIRSTTOKEN),table[i]);
  80:     printf("};\n");
  81:     printf("char *printname[%d] = {\n", SIZE);
  82:     for(p=proc; p->token!=0; p++)
  83:         names[p->token-FIRSTTOKEN] = p->pname;
  84:     for(i=0; i<SIZE; i++)
  85:         printf("/*%s*/\t\"%s\",\n",tokname(i+FIRSTTOKEN),
  86:                         names[i]?names[i]:"");
  87:     printf("};\n");
  88:     exit(0);
  89: }

Defined functions

main defined in line 66; never used

Defined variables

names defined in line 65; used 3 times
proc defined in line 11; used 4 times
sccsid defined in line 2; never used
table defined in line 64; used 3 times

Defined struct's

xx defined in line 7; used 2 times
  • in line 67(2)

Defined macros

NULL defined in line 6; used 4 times
SIZE defined in line 63; used 6 times
Last modified: 1984-12-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 898
Valid CSS Valid XHTML 1.0 Strict