1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1982-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * David Korn <dgk@research.att.com> *
19 ***********************************************************************/
22 #define S_BREAK 1 /* end of token */
23 #define S_EOF 2 /* end of buffer */
24 #define S_NL 3 /* new-line when not a token */
25 #define S_RES 4 /* first character of reserved word */
26 #define S_NAME 5 /* other identifier characters */
27 #define S_REG 6 /* non-special characters */
28 #define S_TILDE 7 /* first char is tilde */
32 #define S_LIT 11 /* literal quote character */
33 #define S_NLTOK 12 /* new-line token */
34 #define S_OP 13 /* operator character */
35 #define S_PAT 14 /* pattern characters * and ? */
36 #define S_EPAT 15 /* pattern char when followed by ( */
37 #define S_EQ 16 /* assignment character */
38 #define S_COM 17 /* comment character */
39 #define S_MOD1 18 /* ${...} modifier character - old quoting */
40 #define S_MOD2 19 /* ${...} modifier character - new quoting */
41 #define S_ERR 20 /* invalid character in ${...} */
42 #define S_SPC1 21 /* special prefix characters after $ */
43 #define S_SPC2 22 /* special characters after $ */
44 #define S_DIG 23 /* digit character after $*/
45 #define S_ALP 24 /* alpahbetic character after $ */
46 #define S_LBRA 25 /* left brace after $ */
47 #define S_RBRA 26 /* right brace after $ */
48 #define S_PAR 27 /* set for $( */
49 #define S_ENDCH 28 /* macro expansion terminator */
50 #define S_SLASH 29 /* / character terminates ~ expansion */
51 #define S_COLON 30 /* for character : */
52 #define S_LABEL 31 /* for goto label */
53 #define S_EDOL 32 /* ends $identifier */
54 #define S_BRACE 33 /* left brace */
55 #define S_DOT 34 /* . char */
56 #define S_META 35 /* | & ; < > inside ${...} reserved for future use */
57 #define S_SPACE S_BREAK /* IFS space characters */
58 #define S_DELIM S_RES /* IFS delimter characters */
59 #define S_MBYTE S_NAME /* IFS first byte of multi-byte char */
60 #define S_BLNK 36 /* space or tab */
61 /* The following must be the highest numbered states */
62 #define S_QUOTE 37 /* double quote character */
63 #define S_GRAVE 38 /* old comsub character */
64 #define S_ESC 39 /* escape character */
65 #define S_DOL 40 /* $ subsitution character */
66 #define S_ESC2 41 /* escape character inside '...' */
68 /* These are the lexical state table names */
82 #include "FEATURE/locale"
89 # define isalpha(x) iswalpha(x)
90 # if defined(iswblank) || _lib_iswblank
92 # define isblank(x) iswblank(x)
94 # if _lib_wctype && _lib_iswctype
95 # define _lib_iswblank -1
97 # define isblank(x) local_iswblank(x)
98 extern int local_iswblank(wchar_t);
104 # define isblank(x) ((x)==' '||(x)=='\t')
110 # define isaname(c) ((c)>0xff?isalpha(c): sh_lexstates[ST_NAME][(c)]==0)
111 # define isaletter(c) ((c)>0xff?isalpha(c): sh_lexstates[ST_DOL][(c)]==S_ALP && (c)!='.')
114 # define mbwide() (0)
116 # define isaname(c) (sh_lexstates[ST_NAME][c]==0)
117 # define isaletter(c) (sh_lexstates[ST_DOL][c]==S_ALP && (c)!='.')
119 #define STATE(s,c) (mbwide()?(c=fcmbstate(s,&NXT,&LEN),NXT):s[c=fcget()])
120 #define isadigit(c) (sh_lexstates[ST_DOL][c]==S_DIG)
121 #define isastchar(c) ((c)=='@' || (c)=='*')
122 #define isexp(c) (sh_lexstates[ST_MACRO][c]==S_PAT||(c)=='$'||(c)=='`')
123 #define ismeta(c) (sh_lexstates[ST_NAME][c]==S_BREAK)
125 extern char *sh_lexstates
[ST_NONE
];
126 extern const char *sh_lexrstates
[ST_NONE
];
127 extern const char e_lexversion
[];
128 extern const char e_lexspace
[];
129 extern const char e_lexslash
[];
130 extern const char e_lexlabignore
[];
131 extern const char e_lexlabunknown
[];
132 extern const char e_lexsyntax1
[];
133 extern const char e_lexsyntax2
[];
134 extern const char e_lexsyntax3
[];
135 extern const char e_lexobsolete1
[];
136 extern const char e_lexobsolete2
[];
137 extern const char e_lexobsolete3
[];
138 extern const char e_lexobsolete4
[];
139 extern const char e_lexobsolete5
[];
140 extern const char e_lexobsolete6
[];
141 extern const char e_lexnonstandard
[];
142 extern const char e_lexusebrace
[];
143 extern const char e_lexusequote
[];
144 extern const char e_lexescape
[];
145 extern const char e_lexquote
[];
146 extern const char e_lexnested
[];
147 extern const char e_lexbadchar
[];
148 extern const char e_lexlongquote
[];
149 extern const char e_lexfuture
[];
150 extern const char e_lexzerobyte
[];
151 extern const char e_lexemptyfor
[];
152 extern const char e_lextypeset
[];