9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

proctab.c (5141B)


      1 #include <stdio.h>
      2 #include <math.h>
      3 #include "awk.h"
      4 #include "y.tab.h"
      5 
      6 static char *printname[92] = {
      7 	(char *) "FIRSTTOKEN",	/* 57346 */
      8 	(char *) "PROGRAM",	/* 57347 */
      9 	(char *) "PASTAT",	/* 57348 */
     10 	(char *) "PASTAT2",	/* 57349 */
     11 	(char *) "XBEGIN",	/* 57350 */
     12 	(char *) "XEND",	/* 57351 */
     13 	(char *) "NL",	/* 57352 */
     14 	(char *) "ARRAY",	/* 57353 */
     15 	(char *) "MATCH",	/* 57354 */
     16 	(char *) "NOTMATCH",	/* 57355 */
     17 	(char *) "MATCHOP",	/* 57356 */
     18 	(char *) "FINAL",	/* 57357 */
     19 	(char *) "DOT",	/* 57358 */
     20 	(char *) "ALL",	/* 57359 */
     21 	(char *) "CCL",	/* 57360 */
     22 	(char *) "NCCL",	/* 57361 */
     23 	(char *) "CHAR",	/* 57362 */
     24 	(char *) "OR",	/* 57363 */
     25 	(char *) "STAR",	/* 57364 */
     26 	(char *) "QUEST",	/* 57365 */
     27 	(char *) "PLUS",	/* 57366 */
     28 	(char *) "AND",	/* 57367 */
     29 	(char *) "BOR",	/* 57368 */
     30 	(char *) "APPEND",	/* 57369 */
     31 	(char *) "EQ",	/* 57370 */
     32 	(char *) "GE",	/* 57371 */
     33 	(char *) "GT",	/* 57372 */
     34 	(char *) "LE",	/* 57373 */
     35 	(char *) "LT",	/* 57374 */
     36 	(char *) "NE",	/* 57375 */
     37 	(char *) "IN",	/* 57376 */
     38 	(char *) "ARG",	/* 57377 */
     39 	(char *) "BLTIN",	/* 57378 */
     40 	(char *) "BREAK",	/* 57379 */
     41 	(char *) "CLOSE",	/* 57380 */
     42 	(char *) "CONTINUE",	/* 57381 */
     43 	(char *) "DELETE",	/* 57382 */
     44 	(char *) "DO",	/* 57383 */
     45 	(char *) "EXIT",	/* 57384 */
     46 	(char *) "FOR",	/* 57385 */
     47 	(char *) "FUNC",	/* 57386 */
     48 	(char *) "SUB",	/* 57387 */
     49 	(char *) "GSUB",	/* 57388 */
     50 	(char *) "IF",	/* 57389 */
     51 	(char *) "INDEX",	/* 57390 */
     52 	(char *) "LSUBSTR",	/* 57391 */
     53 	(char *) "MATCHFCN",	/* 57392 */
     54 	(char *) "NEXT",	/* 57393 */
     55 	(char *) "NEXTFILE",	/* 57394 */
     56 	(char *) "ADD",	/* 57395 */
     57 	(char *) "MINUS",	/* 57396 */
     58 	(char *) "MULT",	/* 57397 */
     59 	(char *) "DIVIDE",	/* 57398 */
     60 	(char *) "MOD",	/* 57399 */
     61 	(char *) "ASSIGN",	/* 57400 */
     62 	(char *) "ASGNOP",	/* 57401 */
     63 	(char *) "ADDEQ",	/* 57402 */
     64 	(char *) "SUBEQ",	/* 57403 */
     65 	(char *) "MULTEQ",	/* 57404 */
     66 	(char *) "DIVEQ",	/* 57405 */
     67 	(char *) "MODEQ",	/* 57406 */
     68 	(char *) "POWEQ",	/* 57407 */
     69 	(char *) "PRINT",	/* 57408 */
     70 	(char *) "PRINTF",	/* 57409 */
     71 	(char *) "SPRINTF",	/* 57410 */
     72 	(char *) "ELSE",	/* 57411 */
     73 	(char *) "INTEST",	/* 57412 */
     74 	(char *) "CONDEXPR",	/* 57413 */
     75 	(char *) "POSTINCR",	/* 57414 */
     76 	(char *) "PREINCR",	/* 57415 */
     77 	(char *) "POSTDECR",	/* 57416 */
     78 	(char *) "PREDECR",	/* 57417 */
     79 	(char *) "VAR",	/* 57418 */
     80 	(char *) "IVAR",	/* 57419 */
     81 	(char *) "VARNF",	/* 57420 */
     82 	(char *) "CALL",	/* 57421 */
     83 	(char *) "NUMBER",	/* 57422 */
     84 	(char *) "STRING",	/* 57423 */
     85 	(char *) "REGEXPR",	/* 57424 */
     86 	(char *) "GETLINE",	/* 57425 */
     87 	(char *) "RETURN",	/* 57426 */
     88 	(char *) "SPLIT",	/* 57427 */
     89 	(char *) "SUBSTR",	/* 57428 */
     90 	(char *) "WHILE",	/* 57429 */
     91 	(char *) "CAT",	/* 57430 */
     92 	(char *) "NOT",	/* 57431 */
     93 	(char *) "UMINUS",	/* 57432 */
     94 	(char *) "POWER",	/* 57433 */
     95 	(char *) "DECR",	/* 57434 */
     96 	(char *) "INCR",	/* 57435 */
     97 	(char *) "INDIRECT",	/* 57436 */
     98 	(char *) "LASTTOKEN",	/* 57437 */
     99 };
    100 
    101 
    102 Cell *(*proctab[92])(Node **, int) = {
    103 	nullproc,	/* FIRSTTOKEN */
    104 	program,	/* PROGRAM */
    105 	pastat,	/* PASTAT */
    106 	dopa2,	/* PASTAT2 */
    107 	nullproc,	/* XBEGIN */
    108 	nullproc,	/* XEND */
    109 	nullproc,	/* NL */
    110 	array,	/* ARRAY */
    111 	matchop,	/* MATCH */
    112 	matchop,	/* NOTMATCH */
    113 	nullproc,	/* MATCHOP */
    114 	nullproc,	/* FINAL */
    115 	nullproc,	/* DOT */
    116 	nullproc,	/* ALL */
    117 	nullproc,	/* CCL */
    118 	nullproc,	/* NCCL */
    119 	nullproc,	/* CHAR */
    120 	nullproc,	/* OR */
    121 	nullproc,	/* STAR */
    122 	nullproc,	/* QUEST */
    123 	nullproc,	/* PLUS */
    124 	boolop,	/* AND */
    125 	boolop,	/* BOR */
    126 	nullproc,	/* APPEND */
    127 	relop,	/* EQ */
    128 	relop,	/* GE */
    129 	relop,	/* GT */
    130 	relop,	/* LE */
    131 	relop,	/* LT */
    132 	relop,	/* NE */
    133 	instat,	/* IN */
    134 	arg,	/* ARG */
    135 	bltin,	/* BLTIN */
    136 	jump,	/* BREAK */
    137 	closefile,	/* CLOSE */
    138 	jump,	/* CONTINUE */
    139 	awkdelete,	/* DELETE */
    140 	dostat,	/* DO */
    141 	jump,	/* EXIT */
    142 	forstat,	/* FOR */
    143 	nullproc,	/* FUNC */
    144 	sub,	/* SUB */
    145 	gsub,	/* GSUB */
    146 	ifstat,	/* IF */
    147 	sindex,	/* INDEX */
    148 	nullproc,	/* LSUBSTR */
    149 	matchop,	/* MATCHFCN */
    150 	jump,	/* NEXT */
    151 	jump,	/* NEXTFILE */
    152 	arith,	/* ADD */
    153 	arith,	/* MINUS */
    154 	arith,	/* MULT */
    155 	arith,	/* DIVIDE */
    156 	arith,	/* MOD */
    157 	assign,	/* ASSIGN */
    158 	nullproc,	/* ASGNOP */
    159 	assign,	/* ADDEQ */
    160 	assign,	/* SUBEQ */
    161 	assign,	/* MULTEQ */
    162 	assign,	/* DIVEQ */
    163 	assign,	/* MODEQ */
    164 	assign,	/* POWEQ */
    165 	printstat,	/* PRINT */
    166 	awkprintf,	/* PRINTF */
    167 	awksprintf,	/* SPRINTF */
    168 	nullproc,	/* ELSE */
    169 	intest,	/* INTEST */
    170 	condexpr,	/* CONDEXPR */
    171 	incrdecr,	/* POSTINCR */
    172 	incrdecr,	/* PREINCR */
    173 	incrdecr,	/* POSTDECR */
    174 	incrdecr,	/* PREDECR */
    175 	nullproc,	/* VAR */
    176 	nullproc,	/* IVAR */
    177 	getnf,	/* VARNF */
    178 	call,	/* CALL */
    179 	nullproc,	/* NUMBER */
    180 	nullproc,	/* STRING */
    181 	nullproc,	/* REGEXPR */
    182 	getline,	/* GETLINE */
    183 	jump,	/* RETURN */
    184 	split,	/* SPLIT */
    185 	substr,	/* SUBSTR */
    186 	whilestat,	/* WHILE */
    187 	cat,	/* CAT */
    188 	boolop,	/* NOT */
    189 	arith,	/* UMINUS */
    190 	arith,	/* POWER */
    191 	nullproc,	/* DECR */
    192 	nullproc,	/* INCR */
    193 	indirect,	/* INDIRECT */
    194 	nullproc,	/* LASTTOKEN */
    195 };
    196 
    197 char *tokname(int n)
    198 {
    199 	static char buf[100];
    200 
    201 	if (n < FIRSTTOKEN || n > LASTTOKEN) {
    202 		sprintf(buf, "token %d", n);
    203 		return buf;
    204 	}
    205 	return printname[n-FIRSTTOKEN];
    206 }