1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #include "awk.h" 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate struct tok 31*7c478bd9Sstevel@tonic-gate { char *tnm; 32*7c478bd9Sstevel@tonic-gate int yval; 33*7c478bd9Sstevel@tonic-gate } tok[] = { 34*7c478bd9Sstevel@tonic-gate "FIRSTTOKEN", 257, 35*7c478bd9Sstevel@tonic-gate "FINAL", 258, 36*7c478bd9Sstevel@tonic-gate "FATAL", 259, 37*7c478bd9Sstevel@tonic-gate "LT", 260, 38*7c478bd9Sstevel@tonic-gate "LE", 261, 39*7c478bd9Sstevel@tonic-gate "GT", 262, 40*7c478bd9Sstevel@tonic-gate "GE", 263, 41*7c478bd9Sstevel@tonic-gate "EQ", 264, 42*7c478bd9Sstevel@tonic-gate "NE", 265, 43*7c478bd9Sstevel@tonic-gate "MATCH", 266, 44*7c478bd9Sstevel@tonic-gate "NOTMATCH", 267, 45*7c478bd9Sstevel@tonic-gate "APPEND", 268, 46*7c478bd9Sstevel@tonic-gate "ADD", 269, 47*7c478bd9Sstevel@tonic-gate "MINUS", 270, 48*7c478bd9Sstevel@tonic-gate "MULT", 271, 49*7c478bd9Sstevel@tonic-gate "DIVIDE", 272, 50*7c478bd9Sstevel@tonic-gate "MOD", 273, 51*7c478bd9Sstevel@tonic-gate "UMINUS", 274, 52*7c478bd9Sstevel@tonic-gate "ASSIGN", 275, 53*7c478bd9Sstevel@tonic-gate "ADDEQ", 276, 54*7c478bd9Sstevel@tonic-gate "SUBEQ", 277, 55*7c478bd9Sstevel@tonic-gate "MULTEQ", 278, 56*7c478bd9Sstevel@tonic-gate "DIVEQ", 279, 57*7c478bd9Sstevel@tonic-gate "MODEQ", 280, 58*7c478bd9Sstevel@tonic-gate "JUMP", 281, 59*7c478bd9Sstevel@tonic-gate "XBEGIN", 282, 60*7c478bd9Sstevel@tonic-gate "XEND", 283, 61*7c478bd9Sstevel@tonic-gate "NL", 284, 62*7c478bd9Sstevel@tonic-gate "PRINT", 285, 63*7c478bd9Sstevel@tonic-gate "PRINTF", 286, 64*7c478bd9Sstevel@tonic-gate "SPRINTF", 287, 65*7c478bd9Sstevel@tonic-gate "SPLIT", 288, 66*7c478bd9Sstevel@tonic-gate "IF", 289, 67*7c478bd9Sstevel@tonic-gate "ELSE", 290, 68*7c478bd9Sstevel@tonic-gate "WHILE", 291, 69*7c478bd9Sstevel@tonic-gate "FOR", 292, 70*7c478bd9Sstevel@tonic-gate "IN", 293, 71*7c478bd9Sstevel@tonic-gate "NEXT", 294, 72*7c478bd9Sstevel@tonic-gate "EXIT", 295, 73*7c478bd9Sstevel@tonic-gate "BREAK", 296, 74*7c478bd9Sstevel@tonic-gate "CONTINUE", 297, 75*7c478bd9Sstevel@tonic-gate "PROGRAM", 298, 76*7c478bd9Sstevel@tonic-gate "PASTAT", 299, 77*7c478bd9Sstevel@tonic-gate "PASTAT2", 300, 78*7c478bd9Sstevel@tonic-gate "ASGNOP", 301, 79*7c478bd9Sstevel@tonic-gate "BOR", 302, 80*7c478bd9Sstevel@tonic-gate "AND", 303, 81*7c478bd9Sstevel@tonic-gate "NOT", 304, 82*7c478bd9Sstevel@tonic-gate "NUMBER", 305, 83*7c478bd9Sstevel@tonic-gate "VAR", 306, 84*7c478bd9Sstevel@tonic-gate "ARRAY", 307, 85*7c478bd9Sstevel@tonic-gate "FNCN", 308, 86*7c478bd9Sstevel@tonic-gate "SUBSTR", 309, 87*7c478bd9Sstevel@tonic-gate "LSUBSTR", 310, 88*7c478bd9Sstevel@tonic-gate "INDEX", 311, 89*7c478bd9Sstevel@tonic-gate "GETLINE", 312, 90*7c478bd9Sstevel@tonic-gate "RELOP", 313, 91*7c478bd9Sstevel@tonic-gate "MATCHOP", 314, 92*7c478bd9Sstevel@tonic-gate "OR", 315, 93*7c478bd9Sstevel@tonic-gate "STRING", 316, 94*7c478bd9Sstevel@tonic-gate "DOT", 317, 95*7c478bd9Sstevel@tonic-gate "CCL", 318, 96*7c478bd9Sstevel@tonic-gate "NCCL", 319, 97*7c478bd9Sstevel@tonic-gate "CHAR", 320, 98*7c478bd9Sstevel@tonic-gate "CAT", 321, 99*7c478bd9Sstevel@tonic-gate "STAR", 322, 100*7c478bd9Sstevel@tonic-gate "PLUS", 323, 101*7c478bd9Sstevel@tonic-gate "QUEST", 324, 102*7c478bd9Sstevel@tonic-gate "POSTINCR", 325, 103*7c478bd9Sstevel@tonic-gate "PREINCR", 326, 104*7c478bd9Sstevel@tonic-gate "POSTDECR", 327, 105*7c478bd9Sstevel@tonic-gate "PREDECR", 328, 106*7c478bd9Sstevel@tonic-gate "INCR", 329, 107*7c478bd9Sstevel@tonic-gate "DECR", 330, 108*7c478bd9Sstevel@tonic-gate "FIELD", 331, 109*7c478bd9Sstevel@tonic-gate "INDIRECT", 332, 110*7c478bd9Sstevel@tonic-gate "JUMPTRUE", 333, 111*7c478bd9Sstevel@tonic-gate "JUMPFALSE", 334, 112*7c478bd9Sstevel@tonic-gate "PUSH", 335, 113*7c478bd9Sstevel@tonic-gate "GETREC", 336, 114*7c478bd9Sstevel@tonic-gate "NEWSTAT", 337, 115*7c478bd9Sstevel@tonic-gate "IN_INIT", 338, 116*7c478bd9Sstevel@tonic-gate "IN_EXIT", 339, 117*7c478bd9Sstevel@tonic-gate "LASTTOKEN", 340, 118*7c478bd9Sstevel@tonic-gate }; 119*7c478bd9Sstevel@tonic-gate ptoken(n) 120*7c478bd9Sstevel@tonic-gate { 121*7c478bd9Sstevel@tonic-gate if (n<128) printf("lex: %c\n", n); 122*7c478bd9Sstevel@tonic-gate else if (n<=256) printf("lex:? %o\n", n); 123*7c478bd9Sstevel@tonic-gate else if (n<LASTTOKEN) printf("lex: %s\n", tok[n-257].tnm); 124*7c478bd9Sstevel@tonic-gate else printf("lex:? %o\n", n); 125*7c478bd9Sstevel@tonic-gate return; 126*7c478bd9Sstevel@tonic-gate } 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate char *tokname(n) 129*7c478bd9Sstevel@tonic-gate { 130*7c478bd9Sstevel@tonic-gate if (n<=256 || n >= LASTTOKEN) 131*7c478bd9Sstevel@tonic-gate n = 257; 132*7c478bd9Sstevel@tonic-gate return (tok[n-257].tnm); 133*7c478bd9Sstevel@tonic-gate } 134