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

Defined functions

main defined in line 61; never used

Defined variables

names defined in line 60; used 2 times
proc defined in line 7; used 4 times
table defined in line 59; used 3 times

Defined struct's

xx defined in line 3; used 2 times
  • in line 62(2)

Defined macros

NULL defined in line 2; used 4 times
SIZE defined in line 58; used 6 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 848
Valid CSS Valid XHTML 1.0 Strict