source: trunk/minix/commands/awk/awk.h@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 4.3 KB
Line 
1/*
2 * a small awk clone
3 *
4 * (C) 1989 Saeko Hirabauashi & Kouichi Hirabayashi
5 *
6 * Absolutely no warranty. Use this software with your own risk.
7 *
8 * Permission to use, copy, modify and distribute this software for any
9 * purpose and without fee is hereby granted, provided that the above
10 * copyright and disclaimer notice.
11 *
12 * This program was written to fit into 64K+64K memory of the Minix 1.2.
13 */
14
15/* lexical/parser tokens and executable statements */
16
17#define FIRSTP 256
18#define ARG 256
19#define ARITH 257
20#define ARRAY 258
21#define ASSIGN 259
22#define CALL 260
23#define CAT 261
24#define COND 262
25#define DELETE 263
26#define DO 264
27#define ELEMENT 265
28#define FIELD 266
29#define FOR 267
30#define FORIN 268
31#define GETLINE 269
32#define IF 270
33#define IN 271
34#define JUMP 272
35#define MATHFUN 273
36#define NULPROC 274
37#define P1STAT 275
38#define P2STAT 276
39#define PRINT 277
40#define PRINT0 278
41#define STRFUN 279
42#define SUBST 280
43#define USRFUN 281
44#define WHILE 282
45#define LASTP 282
46 /* lexical token */
47
48#define ADD 300 /* + */
49#define ADDEQ 301 /* += */
50#define AND 302 /* && */
51#define BEGIN 303 /* BEGIN */
52#define BINAND 304 /* & */
53#define BINOR 305 /* | */
54#define BREAK 306 /* break */
55#define CLOSE 307 /* close */
56#define CONTIN 308 /* continue */
57#define DEC 309 /* -- */
58#define DIV 310 /* / */
59#define DIVEQ 311 /* /= */
60#define ELSE 312 /* else */
61#define END 313 /* END */
62#define EOL 314 /* ; or '\n' */
63#define EQ 315 /* == */
64#define EXIT 316 /* exit */
65#define FUNC 317 /* function */
66#define GE 318 /* >= */
67#define GT 319 /* > */
68#define IDENT 320 /* identifier */
69#define INC 321 /* ++ */
70#define LE 322 /* <= */
71#define LT 323 /* < */
72#define MATCH 324 /* ~ */
73#define MOD 325 /* % */
74#define MODEQ 326 /* %= */
75#define MULT 327 /* * */
76#define MULTEQ 328 /* *= */
77#define NE 329 /* != */
78#define NEXT 330 /* next */
79#define NOMATCH 331 /* !~ */
80#define NOT 332 /* ! */
81#define NUMBER 333 /* integer or floating number */
82#define OR 334 /* || */
83#define POWEQ 335 /* ^= */
84#define POWER 336 /* ^ */
85#define PRINTF 337 /* printf */
86#define REGEXP 338 /* /REG/ */
87#define RETURN 339 /* return */
88#define SHIFTL 340 /* << */
89#define SHIFTR 341 /* >> */
90#define SPRINT 342 /* sprint */
91#define SPRINTF 343 /* sprintf */
92#define STRING 344 /* ".." */
93#define SUB 345 /* - */
94#define SUBEQ 346 /* -= */
95#define SYSTEM 347 /* system */
96#define UMINUS 348 /* - */
97
98/* tokens in parser */
99
100#define VALUE 400 /* value node */
101#define INCDEC 401 /* ++, -- */
102#define PRE 402 /* pre incre/decre */
103#define POST 403 /* post incre/decre */
104
105/* redirect in print(f) statement */
106
107#define R_OUT 410 /* > */
108#define R_APD 411 /* >> */
109#define R_PIPE 412 /* | */
110#define R_IN 413 /* < */
111#define R_PIN 414 /* | getline */
112#define R_POUT 415 /* print | */
113
114/* function */
115
116#define ATAN2 500 /* atan2 */
117#define COS 501 /* cos */
118#define EXP 502 /* exp */
119#define INDEX 503 /* index */
120#define INT 504 /* int */
121#define LENGTH 505 /* length */
122#define LOG 506 /* log */
123#define RAND 507 /* rand */
124#define RGSUB 508 /* gsub */
125#define RMATCH 509 /* match */
126#define RSUB 510 /* sub */
127#define SIN 511 /* sin */
128#define SPLIT 512 /* split */
129#define SQRT 513 /* sqrt */
130#define SRAND 514 /* srand */
131#define SUBSTR 515 /* substr */
132
133/* print(f) options */
134
135#define FORMAT 1024 /* PRINTF, SPRINTF */
136#define STROUT 2048 /* SPRINTF */
137#define PRMASK 0x3ff /* ~(FORMAT|STROUT) */
138
139 /* node - used in parsed tree */
140
141struct node {
142 int n_type; /* node type */
143 struct node *n_next; /* pointer to next node */
144 struct node *n_arg[1]; /* argument (variable length) */
145};
146
147typedef struct node NODE;
148
149 /* object cell */
150
151struct cell {
152 int c_type; /* cell type */
153 char *c_sval; /* string value */
154 double c_fval; /* floating value */
155};
156
157typedef struct cell CELL;
158
159 /* cell type */
160
161#define UDF 0 /* pass parameter */
162#define VAR 1 /* variable */
163#define NUM 2 /* number */
164#define ARR 4 /* array */
165#define STR 8 /* string */
166#define REC 16 /* record */
167#define FLD 32 /* filed */
168#define PAT 64 /* pattern (compiled REGEXPR) */
169#define BRK 128 /* break */
170#define CNT 256 /* continue */
171#define NXT 512 /* next */
172#define EXT 1024 /* exit */
173#define RTN 2048 /* return */
174#define TMP 4096 /* temp cell */
175#define POS 8192 /* argument position */
176#define FUN 16384 /* function */
177
178 /* symbol cell - linked to symbol table */
179
180struct symbol {
181 char *s_name;
182 CELL *s_val;
183 struct symbol *s_next;
184};
185
186typedef struct symbol SYMBOL;
Note: See TracBrowser for help on using the repository browser.