115567Sedward /* 2*62459Sbostic * Copyright (c) 1983, 1993 3*62459Sbostic * The Regents of the University of California. All rights reserved. 433514Sbostic * 542954Sbostic * This code is derived from software contributed to Berkeley by 642954Sbostic * Edward Wang at The University of California, Berkeley. 742954Sbostic * 842835Sbostic * %sccs.include.redist.c% 933514Sbostic * 10*62459Sbostic * @(#)context.h 8.1 (Berkeley) 06/06/93 1115567Sedward */ 1215567Sedward 1316124Sedward #include <stdio.h> 1416124Sedward 1515567Sedward struct context { 1615567Sedward struct context *x_link; /* nested contexts */ 1715855Sedward char x_type; /* tag for union */ 1815855Sedward union { 1915855Sedward struct { /* input is a file */ 2015855Sedward char *X_filename; /* input file name */ 2115855Sedward FILE *X_fp; /* input stream */ 2215855Sedward short X_lineno; /* current line number */ 2315855Sedward char X_bol; /* at beginning of line */ 2415855Sedward char X_noerr; /* don't report errors */ 2515855Sedward struct ww *X_errwin; /* error window */ 2615567Sedward } x_f; 2715855Sedward struct { /* input is a buffer */ 2815855Sedward char *X_buf; /* input buffer */ 2915855Sedward char *X_bufp; /* current position in buf */ 3016448Sedward struct value *X_arg; /* argument for alias */ 3116448Sedward int X_narg; /* number of arguments */ 3215567Sedward } x_b; 3315567Sedward } x_un; 3415855Sedward /* holding place for current token */ 3515855Sedward int x_token; /* the token */ 3615855Sedward struct value x_val; /* values associated with token */ 3715855Sedward /* parser error flags */ 3815855Sedward unsigned x_erred :1; /* had an error */ 3915855Sedward unsigned x_synerred :1; /* had syntax error */ 4015855Sedward unsigned x_abort :1; /* fatal error */ 4115567Sedward }; 4215567Sedward #define x_buf x_un.x_b.X_buf 4315567Sedward #define x_bufp x_un.x_b.X_bufp 4416448Sedward #define x_arg x_un.x_b.X_arg 4516448Sedward #define x_narg x_un.x_b.X_narg 4615567Sedward #define x_filename x_un.x_f.X_filename 4715567Sedward #define x_fp x_un.x_f.X_fp 4815567Sedward #define x_lineno x_un.x_f.X_lineno 4915567Sedward #define x_bol x_un.x_f.X_bol 5015567Sedward #define x_errwin x_un.x_f.X_errwin 5115855Sedward #define x_noerr x_un.x_f.X_noerr 5215567Sedward 5315855Sedward /* x_type values, 0 is reserved */ 5415855Sedward #define X_FILE 1 /* input is a file */ 5515855Sedward #define X_BUF 2 /* input is a buffer */ 5615567Sedward 5715855Sedward struct context cx; /* the current context */ 58