/* * defines for control structures */ #ifndef _KW_D #define _KW_D #define SETBITS 6 #define Elem(x) (1<<(x+SETBITS)) /* * bits 6-15 define a bitfield of control keywords. * These keywords are bitfielded so that the scanner and the parser can * deal with them quickly, but without a lot of code. */ #define IF Elem(0) #define THEN Elem(1) #define ELIF Elem(2) #define ELSE Elem(3) #define FI Elem(4) #define WHILE Elem(5) #define FOR Elem(6) #define DO Elem(7) #define DONE Elem(8) /* * 1-56 are reserved for shell builtins (55 of them) */ #define EMPTY 1 #define EXIT 2 /* exit the shell */ /* * 58-61 are list splicing (lists are terminated by ; - all other list * separators need special splicing.) * NEWLINE is in here for convenience, but we never splice a list with ; !! */ #define NEWLINE 57 /* newline or ; */ /* lowest priority */ #define BG 58 /* &'ed */ /* lowest priority */ #define PIPE 59 /* pipe */ /* highest priority */ #define OR 60 /* || */ /* second level priority */ #define AND 61 /* && */ /* second level priority */ #define ISCOMMAND(ptr) (ptr->c_type < NEWLINE || ptr->c_type > AND) #define ISBINARY(ptr) (ptr->c_type >= NEWLINE && ptr->c_type < AND) #define ISUSERCMD(ptr) (ptr->c_type > AND) /* * the command structure - holds every bit of control structure we can * fabricate (42 bytes long, amazingly enough...) */ typedef struct command { unsigned c_type; /* command */ struct command *c_next; /* pointer to next command */ int c_lineno; /* line (in shellscript) where command is */ char *c_text; /* text of the command */ int c_fs; /* start and end of first argument */ int c_fe; unsigned c_listop; /* if terminated with |, ||, or && */ char *c_filein; /* magic for <