reenabled swaptest. quake should now load data and start on big endian architectures...
[AROS-Contrib.git] / gnu / abc-shell / lex.h
blobe59b28fe743791167439f480095d4e434beb7bf2
1 /*
2 * Source input, lexer and parser
3 */
5 /* $Id$ */
7 #define IDENT 64
9 typedef struct source Source;
10 struct source {
11 const char *str; /* input pointer */
12 int type; /* input type */
13 const char *start; /* start of current buffer */
14 union {
15 char **strv; /* string [] */
16 struct shf *shf; /* shell file */
17 struct tbl *tblp; /* alias (SALIAS) */
18 char *freeme; /* also for SREREAD */
19 } u;
20 char ugbuf[2]; /* buffer for ungetsc() (SREREAD) and
21 * alias (SALIAS) */
22 int line; /* line number */
23 int cmd_offset; /* line number - command number */
24 int errline; /* line the error occured on (0 if not set) */
25 const char *file; /* input file name */
26 int flags; /* SF_* */
27 Area *areap;
28 XString xs; /* input buffer */
29 Source *next; /* stacked source */
32 /* Source.type values */
33 #define SEOF 0 /* input EOF */
34 #define SFILE 1 /* file input */
35 #define SSTDIN 2 /* read stdin */
36 #define SSTRING 3 /* string */
37 #define SWSTR 4 /* string without \n */
38 #define SWORDS 5 /* string[] */
39 #define SWORDSEP 6 /* string[] separator */
40 #define SALIAS 7 /* alias expansion */
41 #define SREREAD 8 /* read ahead to be re-scanned */
43 /* Source.flags values */
44 #define SF_ECHO BIT(0) /* echo input to shlout */
45 #define SF_ALIAS BIT(1) /* faking space at end of alias */
46 #define SF_ALIASEND BIT(2) /* faking space at end of alias */
47 #define SF_TTY BIT(3) /* type == SSTDIN & it is a tty */
50 * states while lexing word
52 #define SBASE 0 /* outside any lexical constructs */
53 #define SWORD 1 /* implicit quoting for substitute() */
54 #define SLETPAREN 2 /* inside (( )), implicit quoting */
55 #define SSQUOTE 3 /* inside '' */
56 #define SDQUOTE 4 /* inside "" */
57 #define SBRACE 5 /* inside ${} */
58 #define SCSPAREN 6 /* inside $() */
59 #define SBQUOTE 7 /* inside `` */
60 #define SASPAREN 8 /* inside $(( )) */
61 #define SHEREDELIM 9 /* parsing <<,<<- delimiter */
62 #define SHEREDQUOTE 10 /* parsing " in <<,<<- delimiter */
63 #define SPATTERN 11 /* parsing *(...|...) pattern (*+?@!) */
64 #define STBRACE 12 /* parsing ${..[#%]..} */
66 typedef union {
67 int i;
68 char *cp;
69 char **wp;
70 struct op *o;
71 struct ioword *iop;
72 } YYSTYPE;
74 /* If something is added here, add it to tokentab[] in syn.c as well */
75 #define LWORD 256
76 #define LOGAND 257 /* && */
77 #define LOGOR 258 /* || */
78 #define BREAK 259 /* ;; */
79 #define IF 260
80 #define THEN 261
81 #define ELSE 262
82 #define ELIF 263
83 #define FI 264
84 #define CASE 265
85 #define ESAC 266
86 #define FOR 267
87 #define SELECT 268
88 #define WHILE 269
89 #define UNTIL 270
90 #define DO 271
91 #define DONE 272
92 #define IN 273
93 #define FUNCTION 274
94 #define TIME 275
95 #define REDIR 276
96 #define MDPAREN 277 /* (( )) */
97 #define BANG 278 /* ! */
98 #define DBRACKET 279 /* [[ .. ]] */
99 #define COPROC 280 /* |& */
100 #define YYERRCODE 300
102 /* flags to yylex */
103 #define CONTIN BIT(0) /* skip new lines to complete command */
104 #define ONEWORD BIT(1) /* single word for substitute() */
105 #define ALIAS BIT(2) /* recognize alias */
106 #define KEYWORD BIT(3) /* recognize keywords */
107 #define LETEXPR BIT(4) /* get expression inside (( )) */
108 #define VARASN BIT(5) /* check for var=word */
109 #define ARRAYVAR BIT(6) /* parse x[1 & 2] as one word */
110 #define ESACONLY BIT(7) /* only accept esac keyword */
111 #define CMDWORD BIT(8) /* parsing simple command (alias related) */
112 #define HEREDELIM BIT(9) /* parsing <<,<<- delimiter */
113 #define HEREDOC BIT(10) /* parsing heredoc */
115 #define HERES 10 /* max << in line */
117 EXTERN Source *source; /* yyparse/yylex source */
118 EXTERN YYSTYPE yylval; /* result from yylex */
119 EXTERN struct ioword *heres [HERES], **herep;
120 EXTERN char ident [IDENT+1];
122 #ifdef HISTORY
123 # define HISTORYSIZE 500 /* size of saved history */
125 EXTERN char **history; /* saved commands */
126 EXTERN char **histptr; /* last history item */
127 EXTERN int histsize; /* history size */
128 #endif /* HISTORY */