xref: /titanic_44/usr/src/lib/libshell/common/data/lexstates.c (revision 3e14f97f673e8a630f076077de35afdd43dc1587)
1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin *                                                                      *
3da2e3ebdSchin *               This software is part of the ast package               *
4*3e14f97fSRoger A. Faulkner *          Copyright (c) 1982-2010 AT&T Intellectual Property          *
5da2e3ebdSchin *                      and is licensed under the                       *
6da2e3ebdSchin *                  Common Public License, Version 1.0                  *
77c2fbfb3SApril Chin *                    by AT&T Intellectual Property                     *
8da2e3ebdSchin *                                                                      *
9da2e3ebdSchin *                A copy of the License is available at                 *
10da2e3ebdSchin *            http://www.opensource.org/licenses/cpl1.0.txt             *
11da2e3ebdSchin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12da2e3ebdSchin *                                                                      *
13da2e3ebdSchin *              Information and Software Systems Research               *
14da2e3ebdSchin *                            AT&T Research                             *
15da2e3ebdSchin *                           Florham Park NJ                            *
16da2e3ebdSchin *                                                                      *
17da2e3ebdSchin *                  David Korn <dgk@research.att.com>                   *
18da2e3ebdSchin *                                                                      *
19da2e3ebdSchin ***********************************************************************/
20da2e3ebdSchin #pragma prototyped
21da2e3ebdSchin 
22da2e3ebdSchin #include	<ast.h>
23da2e3ebdSchin 
24da2e3ebdSchin #include	"FEATURE/options"
25da2e3ebdSchin #include	"lexstates.h"
26da2e3ebdSchin 
27da2e3ebdSchin 
28da2e3ebdSchin /*
29da2e3ebdSchin  * This is the initial state for tokens
30da2e3ebdSchin  */
31da2e3ebdSchin static const char sh_lexstate0[256] =
32da2e3ebdSchin {
33da2e3ebdSchin 	S_EOF,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
34da2e3ebdSchin #if SHOPT_CRNL
35da2e3ebdSchin 	S_REG,	0,	S_NLTOK,S_REG,	S_REG,	0,	S_REG,	S_REG,
36da2e3ebdSchin #else
37da2e3ebdSchin 	S_REG,	0,	S_NLTOK,S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
38da2e3ebdSchin #endif /* SHOPT_CRNL */
39da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
40da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
41da2e3ebdSchin 
42da2e3ebdSchin 	0,	S_REG,	S_REG,	S_COM,	S_REG,	S_REG,	S_OP,	S_REG,
43da2e3ebdSchin 	S_OP,	S_OP,	S_REG,	S_REG,	S_REG,	S_REG,	S_NAME,	S_REG,
44da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
45da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_OP,	S_OP,	S_REG,	S_OP,	S_REG,
46da2e3ebdSchin 
47da2e3ebdSchin 	S_REG,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,
48da2e3ebdSchin 	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,
49da2e3ebdSchin 	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,
50da2e3ebdSchin 	S_NAME,	S_NAME,	S_NAME,	S_REG,	S_REG,	S_REG,	S_REG,	S_NAME,
51da2e3ebdSchin 
52da2e3ebdSchin 	S_REG,	S_NAME,	S_NAME,	S_RES,	S_RES,	S_RES,	S_RES,	S_NAME,
53da2e3ebdSchin #if SHOPT_NAMESPACE
54da2e3ebdSchin 	S_NAME,	S_RES,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_RES,	S_NAME,
55da2e3ebdSchin #else
56da2e3ebdSchin 	S_NAME,	S_RES,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,	S_NAME,
57da2e3ebdSchin #endif /* SHOPT_NAMESPACE */
58da2e3ebdSchin 	S_NAME,	S_NAME,	S_NAME,	S_RES,	S_RES,	S_RES,	S_NAME,	S_RES,
597c2fbfb3SApril Chin 	S_NAME,	S_NAME,	S_NAME,	S_BRACE,S_OP,	S_BRACE,S_TILDE,S_REG,
60da2e3ebdSchin 
61da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
62da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
63da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
64da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
65da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
66da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
67da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
68da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
69da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
70da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
71da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
72da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
73da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
74da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
75da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
76da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
77da2e3ebdSchin };
78da2e3ebdSchin 
79da2e3ebdSchin /*
80da2e3ebdSchin  * This state is for identifiers
81da2e3ebdSchin  */
82da2e3ebdSchin static const char sh_lexstate1[256] =
83da2e3ebdSchin {
84da2e3ebdSchin 	S_EOF,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
85da2e3ebdSchin #if SHOPT_CRNL
86da2e3ebdSchin 	S_REG,	S_BREAK,S_BREAK,S_REG,	S_REG,	S_BREAK,S_REG,	S_REG,
87da2e3ebdSchin #else
88da2e3ebdSchin 	S_REG,	S_BREAK,S_BREAK,S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
89da2e3ebdSchin #endif /* SHOPT_CRNL */
90da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
91da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
92da2e3ebdSchin 
93da2e3ebdSchin 	S_BREAK,S_EPAT,	S_QUOTE,S_REG,	S_DOL,	S_EPAT,	S_BREAK,S_LIT,
94da2e3ebdSchin 	S_BREAK,S_BREAK,S_PAT,	S_EPAT,	S_REG,	S_EPAT,	S_DOT,	S_REG,
95da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
96da2e3ebdSchin 	0,	0,	S_LABEL,S_BREAK,S_BREAK,S_EQ,	S_BREAK,S_PAT,
97da2e3ebdSchin 
98da2e3ebdSchin 	S_EPAT,	0,	0,	0,	0,	0,	0,	0,
99da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
100da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
101da2e3ebdSchin 	0,	0,	0,	S_BRACT,S_ESC,	S_REG,	S_REG,	0,
102da2e3ebdSchin 
103da2e3ebdSchin 	S_GRAVE,0,	0,	0,	0,	0,	0,	0,
104da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
105da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
106da2e3ebdSchin 	0,	0,	0,	S_BRACE,S_BREAK,S_BRACE,S_EPAT,	S_REG,
107da2e3ebdSchin 
108da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
109da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
110da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
111da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
112da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
113da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
114da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
115da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
116da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
117da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
118da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
119da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
120da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
121da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
122da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
123da2e3ebdSchin 	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,	S_REG,
124da2e3ebdSchin };
125da2e3ebdSchin 
126da2e3ebdSchin static const char sh_lexstate2[256] =
127da2e3ebdSchin {
128da2e3ebdSchin 	S_EOF,	0,	0,	0,	0,	0,	0,	0,
129da2e3ebdSchin #if SHOPT_CRNL
130da2e3ebdSchin 	0,	S_BREAK,S_BREAK,0,	0,	S_BREAK,0,	0,
131da2e3ebdSchin #else
132da2e3ebdSchin 	0,	S_BREAK,S_BREAK,0,	0,	0,	0,	0,
133da2e3ebdSchin #endif /* SHOPT_CRNL */
134da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
135da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
136da2e3ebdSchin 
137da2e3ebdSchin 	S_BREAK,S_EPAT,	S_QUOTE,0,	S_DOL,	S_EPAT,	S_BREAK,S_LIT,
138da2e3ebdSchin 	S_BREAK,S_BREAK,S_PAT,	S_EPAT,	0,	S_EPAT,	0,	0,
139da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
140da2e3ebdSchin 	0,	0,	S_COLON,S_BREAK,S_BREAK,0,	S_BREAK,S_PAT,
141da2e3ebdSchin 
142da2e3ebdSchin 	S_EPAT,	0,	0,	0,	0,	0,	0,	0,
143da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
144da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
145da2e3ebdSchin 	0,	0,	0,	S_PAT,	S_ESC,	0,	0,	0,
146da2e3ebdSchin 
147da2e3ebdSchin 	S_GRAVE,0,	0,	0,	0,	0,	0,	0,
148da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
149da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
150da2e3ebdSchin 	0,	0,	0,	S_BRACE,S_BREAK,S_BRACE,S_EPAT,	0,
151da2e3ebdSchin };
152da2e3ebdSchin 
153da2e3ebdSchin /*
154da2e3ebdSchin  * for skipping over  '...'
155da2e3ebdSchin  */
156da2e3ebdSchin static const char sh_lexstate3[256] =
157da2e3ebdSchin {
158da2e3ebdSchin 	S_EOF,	0,	0,	0,	0,	0,	0,	0,
159da2e3ebdSchin 	0,	0,	S_NL,	0,	0,	0,	0,	0,
160da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
161da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
162da2e3ebdSchin 
163da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	S_LIT,
164da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
165da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
166da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
167da2e3ebdSchin 
168da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
169da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
170da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
171da2e3ebdSchin 	0,	0,	0,	0,	S_ESC2,	0,	0,	0
172da2e3ebdSchin };
173da2e3ebdSchin 
174da2e3ebdSchin /*
175da2e3ebdSchin  * for skipping over  "..." and `...`
176da2e3ebdSchin  */
177da2e3ebdSchin static const char sh_lexstate4[256] =
178da2e3ebdSchin {
179da2e3ebdSchin 	S_EOF,	0,	0,	0,	0,	0,	0,	0,
180da2e3ebdSchin 	0,	0,	S_NL,	0,	0,	0,	0,	0,
181da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
182da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
183da2e3ebdSchin 	0,	0,	S_QUOTE,0,	S_DOL,	0,	0,	0,
184da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
185da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
186da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
187da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
188da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
189da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
190da2e3ebdSchin 	0,	0,	0,	0,	S_ESC,	0,	0,	0,
191da2e3ebdSchin 	S_GRAVE,0,	0,	0,	0,	0,	0,	0,
192da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
193da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
194da2e3ebdSchin 	0,	0,	0,	0,	0,	S_RBRA,	0,	0
195da2e3ebdSchin };
196da2e3ebdSchin 
197da2e3ebdSchin /*
198da2e3ebdSchin  * for skipping over ?(...), [...]
199da2e3ebdSchin  */
200da2e3ebdSchin static const char sh_lexstate5[256] =
201da2e3ebdSchin {
202da2e3ebdSchin 	S_EOF,	0,	0,	0,	0,	0,	0,	0,
203da2e3ebdSchin 	0,	S_BLNK,	S_NL,	0,	0,	0,	0,	0,
204da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
205da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
206da2e3ebdSchin 	S_BLNK,	0,	S_QUOTE,0,	S_DOL,	0,	S_META,	S_LIT,
207da2e3ebdSchin 	S_PUSH,	S_POP,	0,	0,	0,	0,	0,	0,
208da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
209da2e3ebdSchin 	0,	0,	0,	S_POP,	S_META,	0,	S_META,	0,
210da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
211da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
212da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
213da2e3ebdSchin 	0,	0,	0,	S_BRACT,S_ESC,	S_POP,	0,	0,
214da2e3ebdSchin 	S_GRAVE,0,	0,	0,	0,	0,	0,	0,
215da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
216da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
217da2e3ebdSchin 	0,	0,	0,	S_BRACE,S_META,	S_POP,	0,	0
218da2e3ebdSchin };
219da2e3ebdSchin 
220da2e3ebdSchin /*
221da2e3ebdSchin  * Defines valid expansion characters
222da2e3ebdSchin  */
223da2e3ebdSchin static const char sh_lexstate6[256] =
224da2e3ebdSchin {
225da2e3ebdSchin 	S_EOF,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
226da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
227da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
228da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
229da2e3ebdSchin 
230da2e3ebdSchin 	S_ERR,	S_SPC1,	S_ERR,	S_SPC1,	S_SPC2,	S_ERR,	S_ERR,	S_LIT,
231da2e3ebdSchin 	S_PAR,	S_ERR,	S_SPC2,	S_ERR,	S_ERR,	S_SPC2,	S_ALP,	S_ERR,
232da2e3ebdSchin 	S_DIG,	S_DIG,	S_DIG,	S_DIG,	S_DIG,	S_DIG,	S_DIG,	S_DIG,
233da2e3ebdSchin 	S_DIG,	S_DIG,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_SPC2,
234da2e3ebdSchin 
235da2e3ebdSchin #if SHOPT_TYPEDEF
236da2e3ebdSchin 	S_SPC1,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,
237da2e3ebdSchin #else
238da2e3ebdSchin 	S_SPC2,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,
239da2e3ebdSchin #endif
240da2e3ebdSchin 	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,
241da2e3ebdSchin 	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,
242da2e3ebdSchin 	S_ALP,	S_ALP,	S_ALP,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ALP,
243da2e3ebdSchin 
244da2e3ebdSchin 	S_ERR,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,
245da2e3ebdSchin 	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,
246da2e3ebdSchin 	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,	S_ALP,
247da2e3ebdSchin 	S_ALP,	S_ALP,	S_ALP,	S_LBRA,	S_ERR,	S_RBRA,	S_ERR,	S_ERR,
248da2e3ebdSchin 
249da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
250da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
251da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
252da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
253da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
254da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
255da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
256da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
257da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
258da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
259da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
260da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
261da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
262da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
263da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
264da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
265da2e3ebdSchin };
266da2e3ebdSchin 
267da2e3ebdSchin /*
268da2e3ebdSchin  * for skipping over ${...} until modifier
269da2e3ebdSchin  */
270da2e3ebdSchin static const char sh_lexstate7[256] =
271da2e3ebdSchin {
272da2e3ebdSchin 	S_EOF,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
273da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
274da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
275da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
276da2e3ebdSchin 
277da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_MOD2,	S_ERR,	S_MOD2,	S_ERR,	S_ERR,
278da2e3ebdSchin 	S_ERR,	S_ERR,	S_MOD1,	S_MOD1,	S_ERR,	S_MOD1,	S_DOT,	S_MOD2,
279da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
280da2e3ebdSchin 	0,	0,	S_MOD1,	S_ERR,	S_ERR,	S_MOD1,	S_ERR,	S_MOD1,
281da2e3ebdSchin 
282da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
283da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
284da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
285da2e3ebdSchin 	0,	0,	0,	S_BRACT,S_ESC,	S_ERR,	S_ERR,	0,
286da2e3ebdSchin 
287da2e3ebdSchin 	S_ERR,	0,	0,	0,	0,	0,	0,	0,
288da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
289da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
290da2e3ebdSchin 	0,	0,	0,	S_ERR,	S_ERR,	S_POP,	S_ERR,	S_ERR,
291da2e3ebdSchin 
292da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
293da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
294da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
295da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
296da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
297da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
298da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
299da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
300da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
301da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
302da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
303da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
304da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
305da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
306da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
307da2e3ebdSchin 	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,	S_ERR,
308da2e3ebdSchin };
309da2e3ebdSchin 
310da2e3ebdSchin /*
311da2e3ebdSchin  * This state is for $name
312da2e3ebdSchin  */
313da2e3ebdSchin static const char sh_lexstate8[256] =
314da2e3ebdSchin {
315da2e3ebdSchin 	S_EOF,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
316da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
317da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
318da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
319da2e3ebdSchin 
320da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
321da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
322da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
323da2e3ebdSchin 	0,	0,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
324da2e3ebdSchin 
325da2e3ebdSchin 	S_EDOL,	0,	0,	0,	0,	0,	0,	0,
326da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
327da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
328da2e3ebdSchin 	0,	0,	0,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	0,
329da2e3ebdSchin 
330da2e3ebdSchin 	S_EDOL,0,	0,	0,	0,	0,	0,	0,
331da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
332da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
333da2e3ebdSchin 	0,	0,	0,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
334da2e3ebdSchin 
335da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
336da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
337da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
338da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
339da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
340da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
341da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
342da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
343da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
344da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
345da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
346da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
347da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
348da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
349da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
350da2e3ebdSchin 	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,	S_EDOL,
351da2e3ebdSchin };
352da2e3ebdSchin 
353da2e3ebdSchin /*
354da2e3ebdSchin  * This is used for macro expansion
355da2e3ebdSchin  */
356da2e3ebdSchin static const char sh_lexstate9[256] =
357da2e3ebdSchin {
358da2e3ebdSchin 	S_EOF,	0,	0,	0,	0,	0,	0,	0,
359da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
360da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
361da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
362da2e3ebdSchin 	0,	0,	S_QUOTE,0,	S_DOL,	0,	S_PAT,	S_LIT,
3637c2fbfb3SApril Chin 	S_PAT,	S_PAT,	S_PAT,	0,	S_COM,	0,	S_DOT,	S_SLASH,
3647c2fbfb3SApril Chin 	S_DIG,	S_DIG,	S_DIG,	S_DIG,	S_DIG,	S_DIG,	S_DIG,	S_DIG,
365da2e3ebdSchin 	S_DIG,	S_DIG,	S_COLON,0,	0,	S_EQ,	0,	S_PAT,
366da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
367da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
368da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
369da2e3ebdSchin 	0,	0,	0,	S_BRACT,S_ESC,	S_ENDCH,0,	0,
370da2e3ebdSchin 	S_GRAVE,0,	0,	0,	0,	0,	0,	0,
371da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
372da2e3ebdSchin 	0,	0,	0,	0,	0,	0,	0,	0,
373da2e3ebdSchin #if SHOPT_BRACEPAT
374da2e3ebdSchin 	0,	0,	0,	S_BRACE,S_PAT,	S_ENDCH,0,	0
375da2e3ebdSchin #else
376da2e3ebdSchin 	0,	0,	0,	0,	S_PAT,	S_ENDCH,0,	0
377da2e3ebdSchin #endif /* SHOPT_BRACEPAT */
378da2e3ebdSchin };
379da2e3ebdSchin 
380da2e3ebdSchin const char *sh_lexrstates[ST_NONE] =
381da2e3ebdSchin {
382da2e3ebdSchin 	sh_lexstate0, sh_lexstate1, sh_lexstate2, sh_lexstate3,
383da2e3ebdSchin 	sh_lexstate4, sh_lexstate5, sh_lexstate6, sh_lexstate7,
384da2e3ebdSchin 	sh_lexstate8, sh_lexstate9, sh_lexstate5
385da2e3ebdSchin };
386da2e3ebdSchin 
387da2e3ebdSchin 
388da2e3ebdSchin const char e_lexversion[]	= "%d: invalid binary script version";
389da2e3ebdSchin const char e_lexspace[]		= "line %d: use space or tab to separate operators %c and %c";
390*3e14f97fSRoger A. Faulkner const char e_lexslash[]		= "line %d: $ not preceded by \\";
391da2e3ebdSchin const char e_lexsyntax1[]	= "syntax error at line %d: `%s' %s";
392da2e3ebdSchin const char e_lexsyntax2[]	= "syntax error: `%s' %s";
393da2e3ebdSchin const char e_lexsyntax3[]	= "syntax error at line %d: duplicate label %s";
394da2e3ebdSchin const char e_lexlabignore[]	= "line %d: label %s ignored";
395da2e3ebdSchin const char e_lexlabunknown[]	= "line %d: %s unknown label";
396da2e3ebdSchin const char e_lexobsolete1[]	= "line %d: `...` obsolete, use $(...)";
397da2e3ebdSchin const char e_lexobsolete2[]	= "line %d: -a obsolete, use -e";
398da2e3ebdSchin const char e_lexobsolete3[]	= "line %d: '=' obsolete, use '=='";
399da2e3ebdSchin const char e_lexobsolete4[]	= "line %d: %s within [[...]] obsolete, use ((...))";
400da2e3ebdSchin const char e_lexobsolete5[]	= "line %d: set %s obsolete";
401da2e3ebdSchin const char e_lexobsolete6[]	= "line %d: `{' instead of `in' is obsolete";
40234f9b3eeSRoland Mainz const char e_lexnonstandard[]	= "line %d: `&>file' is nonstandard -- interpreted as `>file 2>&1' for profile input only";
403da2e3ebdSchin const char e_lexusebrace[]	= "line %d: use braces to avoid ambiguities with $id[...]";
404da2e3ebdSchin const char e_lexusequote[]	= "line %d: %c within ${} should be quoted";
405da2e3ebdSchin const char e_lexescape[]	= "line %d: escape %c to avoid ambiguities";
406da2e3ebdSchin const char e_lexquote[]		= "line %d: quote %c to avoid ambiguities";
407da2e3ebdSchin const char e_lexnested[]	= "line %d: spaces required for nested subshell";
408da2e3ebdSchin const char e_lexbadchar[]	= "%c: invalid character in expression - %s";
409da2e3ebdSchin const char e_lexfuture[]	= "line %d: \\ in front of %c reserved for future use";
410da2e3ebdSchin const char e_lexlongquote[]	= "line %d: %c quote may be missing";
411da2e3ebdSchin const char e_lexzerobyte[]	= "zero byte";
412da2e3ebdSchin const char e_lexemptyfor[]	= "line %d: empty for list";
4137c2fbfb3SApril Chin const char e_lextypeset[]	= "line %d: %s invalid typeset option order";
414