2 * Source input, lexer and parser
5 /* $Id: lex.h,v 1.4 1994/05/31 13:34:34 michael Exp $ */
9 typedef struct source Source
;
11 const char *str
; /* input pointer */
12 int type
; /* input type */
13 const char *start
; /* start of current buffer */
15 char **strv
; /* string [] */
16 struct shf
*shf
; /* shell file */
17 struct tbl
*tblp
; /* alias (SALIAS) */
18 char *freeme
; /* also for SREREAD */
20 char ugbuf
[2]; /* buffer for ungetsc() (SREREAD) and
22 int line
; /* line number */
23 int errline
; /* line the error occured on (0 if not set) */
24 const char *file
; /* input file name */
27 XString xs
; /* input buffer */
28 Source
*next
; /* stacked source */
31 /* Source.type values */
32 #define SEOF 0 /* input EOF */
33 #define SFILE 1 /* file input */
34 #define SSTDIN 2 /* read stdin */
35 #define SSTRING 3 /* string */
36 #define SWSTR 4 /* string without \n */
37 #define SWORDS 5 /* string[] */
38 #define SWORDSEP 6 /* string[] seperator */
39 #define SALIAS 7 /* alias expansion */
40 #define SREREAD 8 /* read ahead to be re-scanned */
42 /* Source.flags values */
43 #define SF_ECHO BIT(0) /* echo input to shlout */
44 #define SF_ALIAS BIT(1) /* faking space at end of alias */
45 #define SF_ALIASEND BIT(2) /* faking space at end of alias */
46 #define SF_TTY BIT(3) /* type == SSTDIN & it is a tty */
47 #define SF_FIRST BIT(4) /* initial state (to ignore UTF-8 BOM) */
57 /* If something is added here, add it to tokentab[] in syn.c as well */
59 #define LOGAND 257 /* && */
60 #define LOGOR 258 /* || */
61 #define BREAK 259 /* ;; */
80 #define MDPAREN 277 /* (( )) */
82 #define BANG 278 /* ! */
83 #define DBRACKET 279 /* [[ .. ]] */
84 #define COPROC 280 /* |& */
88 #define CONTIN BIT(0) /* skip new lines to complete command */
89 #define ONEWORD BIT(1) /* single word for substitute() */
90 #define ALIAS BIT(2) /* recognize alias */
91 #define KEYWORD BIT(3) /* recognize keywords */
92 #define LETEXPR BIT(4) /* get expression inside (( )) */
93 #define VARASN BIT(5) /* check for var=word */
94 #define ARRAYVAR BIT(6) /* parse x[1 & 2] as one word */
95 #define ESACONLY BIT(7) /* only accept esac keyword */
96 #define CMDWORD BIT(8) /* parsing simple command (alias related) */
97 #define HEREDELIM BIT(9) /* parsing <<,<<- delimiter */
98 #define HEREDOC BIT(10) /* parsing heredoc */
100 #define HERES 10 /* max << in line */
102 EXTERN Source
*source
; /* yyparse/yylex source */
103 EXTERN YYSTYPE yylval
; /* result from yylex */
104 EXTERN
struct ioword
*heres
[HERES
], **herep
;
105 EXTERN
char ident
[IDENT
+1];
108 # define HISTORYSIZE 128 /* size of saved history */
110 EXTERN
char **history
; /* saved commands */
111 EXTERN
char **histptr
; /* last history item */
112 EXTERN
int histsize
; /* history size */