17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
237c478bd9Sstevel@tonic-gate /* All Rights Reserved */
247c478bd9Sstevel@tonic-gate
257c478bd9Sstevel@tonic-gate
26*dc5a8425Srobbin #pragma ident "%Z%%M% %I% %E% SMI"
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate #include "awk.h"
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate struct tok
317c478bd9Sstevel@tonic-gate { char *tnm;
327c478bd9Sstevel@tonic-gate int yval;
337c478bd9Sstevel@tonic-gate } tok[] = {
347c478bd9Sstevel@tonic-gate "FIRSTTOKEN", 257,
357c478bd9Sstevel@tonic-gate "FINAL", 258,
367c478bd9Sstevel@tonic-gate "FATAL", 259,
377c478bd9Sstevel@tonic-gate "LT", 260,
387c478bd9Sstevel@tonic-gate "LE", 261,
397c478bd9Sstevel@tonic-gate "GT", 262,
407c478bd9Sstevel@tonic-gate "GE", 263,
417c478bd9Sstevel@tonic-gate "EQ", 264,
427c478bd9Sstevel@tonic-gate "NE", 265,
437c478bd9Sstevel@tonic-gate "MATCH", 266,
447c478bd9Sstevel@tonic-gate "NOTMATCH", 267,
457c478bd9Sstevel@tonic-gate "APPEND", 268,
467c478bd9Sstevel@tonic-gate "ADD", 269,
477c478bd9Sstevel@tonic-gate "MINUS", 270,
487c478bd9Sstevel@tonic-gate "MULT", 271,
497c478bd9Sstevel@tonic-gate "DIVIDE", 272,
507c478bd9Sstevel@tonic-gate "MOD", 273,
517c478bd9Sstevel@tonic-gate "UMINUS", 274,
527c478bd9Sstevel@tonic-gate "ASSIGN", 275,
537c478bd9Sstevel@tonic-gate "ADDEQ", 276,
547c478bd9Sstevel@tonic-gate "SUBEQ", 277,
557c478bd9Sstevel@tonic-gate "MULTEQ", 278,
567c478bd9Sstevel@tonic-gate "DIVEQ", 279,
577c478bd9Sstevel@tonic-gate "MODEQ", 280,
587c478bd9Sstevel@tonic-gate "JUMP", 281,
597c478bd9Sstevel@tonic-gate "XBEGIN", 282,
607c478bd9Sstevel@tonic-gate "XEND", 283,
617c478bd9Sstevel@tonic-gate "NL", 284,
627c478bd9Sstevel@tonic-gate "PRINT", 285,
637c478bd9Sstevel@tonic-gate "PRINTF", 286,
647c478bd9Sstevel@tonic-gate "SPRINTF", 287,
657c478bd9Sstevel@tonic-gate "SPLIT", 288,
667c478bd9Sstevel@tonic-gate "IF", 289,
677c478bd9Sstevel@tonic-gate "ELSE", 290,
687c478bd9Sstevel@tonic-gate "WHILE", 291,
697c478bd9Sstevel@tonic-gate "FOR", 292,
707c478bd9Sstevel@tonic-gate "IN", 293,
717c478bd9Sstevel@tonic-gate "NEXT", 294,
727c478bd9Sstevel@tonic-gate "EXIT", 295,
737c478bd9Sstevel@tonic-gate "BREAK", 296,
747c478bd9Sstevel@tonic-gate "CONTINUE", 297,
757c478bd9Sstevel@tonic-gate "PROGRAM", 298,
767c478bd9Sstevel@tonic-gate "PASTAT", 299,
777c478bd9Sstevel@tonic-gate "PASTAT2", 300,
787c478bd9Sstevel@tonic-gate "ASGNOP", 301,
797c478bd9Sstevel@tonic-gate "BOR", 302,
807c478bd9Sstevel@tonic-gate "AND", 303,
817c478bd9Sstevel@tonic-gate "NOT", 304,
827c478bd9Sstevel@tonic-gate "NUMBER", 305,
837c478bd9Sstevel@tonic-gate "VAR", 306,
847c478bd9Sstevel@tonic-gate "ARRAY", 307,
857c478bd9Sstevel@tonic-gate "FNCN", 308,
867c478bd9Sstevel@tonic-gate "SUBSTR", 309,
877c478bd9Sstevel@tonic-gate "LSUBSTR", 310,
887c478bd9Sstevel@tonic-gate "INDEX", 311,
897c478bd9Sstevel@tonic-gate "GETLINE", 312,
907c478bd9Sstevel@tonic-gate "RELOP", 313,
917c478bd9Sstevel@tonic-gate "MATCHOP", 314,
927c478bd9Sstevel@tonic-gate "OR", 315,
937c478bd9Sstevel@tonic-gate "STRING", 316,
947c478bd9Sstevel@tonic-gate "DOT", 317,
957c478bd9Sstevel@tonic-gate "CCL", 318,
967c478bd9Sstevel@tonic-gate "NCCL", 319,
977c478bd9Sstevel@tonic-gate "CHAR", 320,
987c478bd9Sstevel@tonic-gate "CAT", 321,
997c478bd9Sstevel@tonic-gate "STAR", 322,
1007c478bd9Sstevel@tonic-gate "PLUS", 323,
1017c478bd9Sstevel@tonic-gate "QUEST", 324,
1027c478bd9Sstevel@tonic-gate "POSTINCR", 325,
1037c478bd9Sstevel@tonic-gate "PREINCR", 326,
1047c478bd9Sstevel@tonic-gate "POSTDECR", 327,
1057c478bd9Sstevel@tonic-gate "PREDECR", 328,
1067c478bd9Sstevel@tonic-gate "INCR", 329,
1077c478bd9Sstevel@tonic-gate "DECR", 330,
1087c478bd9Sstevel@tonic-gate "FIELD", 331,
1097c478bd9Sstevel@tonic-gate "INDIRECT", 332,
1107c478bd9Sstevel@tonic-gate "JUMPTRUE", 333,
1117c478bd9Sstevel@tonic-gate "JUMPFALSE", 334,
1127c478bd9Sstevel@tonic-gate "PUSH", 335,
1137c478bd9Sstevel@tonic-gate "GETREC", 336,
1147c478bd9Sstevel@tonic-gate "NEWSTAT", 337,
1157c478bd9Sstevel@tonic-gate "IN_INIT", 338,
1167c478bd9Sstevel@tonic-gate "IN_EXIT", 339,
1177c478bd9Sstevel@tonic-gate "LASTTOKEN", 340,
1187c478bd9Sstevel@tonic-gate };
119*dc5a8425Srobbin void
ptoken(int n)120*dc5a8425Srobbin ptoken(int n)
1217c478bd9Sstevel@tonic-gate {
1227c478bd9Sstevel@tonic-gate if (n < 128) printf("lex: %c\n", n);
1237c478bd9Sstevel@tonic-gate else if (n <= 256) printf("lex:? %o\n", n);
1247c478bd9Sstevel@tonic-gate else if (n < LASTTOKEN) printf("lex: %s\n", tok[n-257].tnm);
1257c478bd9Sstevel@tonic-gate else printf("lex:? %o\n", n);
1267c478bd9Sstevel@tonic-gate }
1277c478bd9Sstevel@tonic-gate
128*dc5a8425Srobbin char *
tokname(n)129*dc5a8425Srobbin tokname(n)
1307c478bd9Sstevel@tonic-gate {
1317c478bd9Sstevel@tonic-gate if (n <= 256 || n >= LASTTOKEN)
1327c478bd9Sstevel@tonic-gate n = 257;
1337c478bd9Sstevel@tonic-gate return (tok[n-257].tnm);
1347c478bd9Sstevel@tonic-gate }
135