]>
Commit | Line | Data |
---|---|---|
726f6388 JA |
1 | /* parser.h -- Everything you wanted to know about the parser, but were |
2 | afraid to ask. */ | |
bb70624e | 3 | |
74091dd4 | 4 | /* Copyright (C) 1995-2021 Free Software Foundation, Inc. |
bb70624e JA |
5 | |
6 | This file is part of GNU Bash, the Bourne Again SHell. | |
7 | ||
3185942a JA |
8 | Bash is free software: you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation, either version 3 of the License, or | |
11 | (at your option) any later version. | |
bb70624e | 12 | |
3185942a JA |
13 | Bash is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
bb70624e | 17 | |
3185942a JA |
18 | You should have received a copy of the GNU General Public License |
19 | along with Bash. If not, see <http://www.gnu.org/licenses/>. | |
20 | */ | |
bb70624e | 21 | |
ccc6cda3 JA |
22 | #if !defined (_PARSER_H_) |
23 | # define _PARSER_H_ | |
726f6388 | 24 | |
726f6388 JA |
25 | # include "command.h" |
26 | # include "input.h" | |
ccc6cda3 | 27 | |
3185942a | 28 | /* Possible states for the parser that require it to do special things. */ |
0001803f CR |
29 | #define PST_CASEPAT 0x000001 /* in a case pattern list */ |
30 | #define PST_ALEXPNEXT 0x000002 /* expand next word for aliases */ | |
31 | #define PST_ALLOWOPNBRC 0x000004 /* allow open brace for function def */ | |
32 | #define PST_NEEDCLOSBRC 0x000008 /* need close brace */ | |
74091dd4 | 33 | #define PST_DBLPAREN 0x000010 /* double-paren parsing - unused */ |
0001803f CR |
34 | #define PST_SUBSHELL 0x000020 /* ( ... ) subshell */ |
35 | #define PST_CMDSUBST 0x000040 /* $( ... ) command substitution */ | |
36 | #define PST_CASESTMT 0x000080 /* parsing a case statement */ | |
37 | #define PST_CONDCMD 0x000100 /* parsing a [[...]] command */ | |
38 | #define PST_CONDEXPR 0x000200 /* parsing the guts of [[...]] */ | |
495aee44 | 39 | #define PST_ARITHFOR 0x000400 /* parsing an arithmetic for command - unused */ |
0001803f CR |
40 | #define PST_ALEXPAND 0x000800 /* OK to expand aliases - unused */ |
41 | #define PST_EXTPAT 0x001000 /* parsing an extended shell pattern */ | |
42 | #define PST_COMPASSIGN 0x002000 /* parsing x=(...) compound assignment */ | |
43 | #define PST_ASSIGNOK 0x004000 /* assignment statement ok in this context */ | |
44 | #define PST_EOFTOKEN 0x008000 /* yylex checks against shell_eof_token */ | |
45 | #define PST_REGEXP 0x010000 /* parsing an ERE/BRE as a single word */ | |
46 | #define PST_HEREDOC 0x020000 /* reading body of here-document */ | |
47 | #define PST_REPARSE 0x040000 /* re-parsing in parse_string_to_word_list */ | |
ac50fbac | 48 | #define PST_REDIRLIST 0x080000 /* parsing a list of redirections preceding a simple command name */ |
d233b485 | 49 | #define PST_COMMENT 0x100000 /* parsing a shell comment; used by aliases */ |
ddf3f643 | 50 | #define PST_ENDALIAS 0x200000 /* just finished expanding and consuming an alias */ |
74091dd4 CR |
51 | #define PST_NOEXPAND 0x400000 /* don't expand anything in read_token_word; for command substitution */ |
52 | #define PST_NOERROR 0x800000 /* don't print error messages in yyerror */ | |
8c9524f9 | 53 | #define PST_STRING 0x1000000 /* parsing a string to a command or word list */ |
3185942a | 54 | |
ccc6cda3 JA |
55 | /* Definition of the delimiter stack. Needed by parse.y and bashhist.c. */ |
56 | struct dstack { | |
57 | /* DELIMITERS is a stack of the nested delimiters that we have | |
58 | encountered so far. */ | |
59 | char *delimiters; | |
60 | ||
61 | /* Offset into the stack of delimiters. */ | |
62 | int delimiter_depth; | |
63 | ||
64 | /* How many slots are allocated to DELIMITERS. */ | |
65 | int delimiter_space; | |
66 | }; | |
67 | ||
495aee44 CR |
68 | /* States we can be in while scanning a ${...} expansion. Shared between |
69 | parse.y and subst.c */ | |
70 | #define DOLBRACE_PARAM 0x01 | |
71 | #define DOLBRACE_OP 0x02 | |
72 | #define DOLBRACE_WORD 0x04 | |
73 | ||
ac50fbac CR |
74 | #define DOLBRACE_QUOTE 0x40 /* single quote is special in double quotes */ |
75 | #define DOLBRACE_QUOTE2 0x80 /* single quote is semi-special in double quotes */ | |
495aee44 | 76 | |
d233b485 CR |
77 | /* variable declarations from parse.y */ |
78 | extern struct dstack dstack; | |
79 | ||
80 | extern char *primary_prompt; | |
81 | extern char *secondary_prompt; | |
82 | ||
83 | extern char *current_prompt_string; | |
84 | ||
85 | extern char *ps1_prompt; | |
86 | extern char *ps2_prompt; | |
87 | extern char *ps0_prompt; | |
88 | ||
89 | extern int expand_aliases; | |
90 | extern int current_command_line_count; | |
91 | extern int saved_command_line_count; | |
92 | extern int shell_eof_token; | |
93 | extern int current_token; | |
94 | extern int parser_state; | |
95 | extern int need_here_doc; | |
96 | ||
97 | extern int ignoreeof; | |
98 | extern int eof_encountered; | |
99 | extern int eof_encountered_limit; | |
100 | ||
101 | extern int line_number, line_number_base; | |
102 | ||
ccc6cda3 | 103 | #endif /* _PARSER_H_ */ |