xref: /original-bsd/usr.bin/window/context.h (revision e85b5252)
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Edward Wang at The University of California, Berkeley.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)context.h	8.1 (Berkeley) 06/06/93
11  */
12 
13 #include <stdio.h>
14 
15 struct context {
16 	struct context *x_link;		/* nested contexts */
17 	char x_type;			/* tag for union */
18 	union {
19 		struct {	/* input is a file */
20 			char *X_filename;	/* input file name */
21 			FILE *X_fp;		/* input stream */
22 			short X_lineno;		/* current line number */
23 			char X_bol;		/* at beginning of line */
24 			char X_noerr;		/* don't report errors */
25 			struct ww *X_errwin;	/* error window */
26 		} x_f;
27 		struct {	/* input is a buffer */
28 			char *X_buf;		/* input buffer */
29 			char *X_bufp;		/* current position in buf */
30 			struct value *X_arg;	/* argument for alias */
31 			int X_narg;		/* number of arguments */
32 		} x_b;
33 	} x_un;
34 		/* holding place for current token */
35 	int x_token;			/* the token */
36 	struct value x_val;		/* values associated with token */
37 		/* parser error flags */
38 	unsigned x_erred :1;		/* had an error */
39 	unsigned x_synerred :1;		/* had syntax error */
40 	unsigned x_abort :1;		/* fatal error */
41 };
42 #define x_buf		x_un.x_b.X_buf
43 #define x_bufp		x_un.x_b.X_bufp
44 #define x_arg		x_un.x_b.X_arg
45 #define x_narg		x_un.x_b.X_narg
46 #define x_filename	x_un.x_f.X_filename
47 #define x_fp		x_un.x_f.X_fp
48 #define x_lineno	x_un.x_f.X_lineno
49 #define x_bol		x_un.x_f.X_bol
50 #define x_errwin	x_un.x_f.X_errwin
51 #define x_noerr		x_un.x_f.X_noerr
52 
53 	/* x_type values, 0 is reserved */
54 #define X_FILE		1		/* input is a file */
55 #define X_BUF		2		/* input is a buffer */
56 
57 struct context cx;			/* the current context */
58