1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 #if defined(sun)
27 #pragma ident	"@(#)sym.h	1.8	05/06/08 SMI"	/* SVr4.0 1.6	*/
28 #endif
29 /*
30  * Copyright 2009-2020 J. Schilling
31  * @(#)sym.h	1.13 20/03/13 2009-2020 J. Schilling
32  */
33 /*
34  *	UNIX shell
35  */
36 
37 
38 /* symbols for parsing */
39 #define	NOTSYM	'!'		/* "!"		*/
40 #define	DOSYM	0405		/* "do"		*/
41 #define	FISYM	0420		/* "fi"		*/
42 #define	EFSYM	0422		/* "elif"	*/
43 #define	ELSYM	0421		/* "else"	*/
44 #define	INSYM	0412		/* "in"		*/
45 #define	BRSYM	0406		/* "{"		*/
46 #define	KTSYM	0450		/* "}"		*/
47 #define	THSYM	0444		/* "then"	*/
48 #define	ODSYM	0441		/* "done"	*/
49 #define	ESSYM	0442		/* "esac"	*/
50 #define	IFSYM	0436		/* "if"		*/
51 #define	FORSYM	0435		/* "for"	*/
52 #define	WHSYM	0433		/* "while"	*/
53 #define	UNSYM	0427		/* "until"	*/
54 #define	CASYM	0417		/* "case"	*/
55 #define	SELSYM 	0470		/* "select"	*/
56 #define	TIMSYM	0474		/* "time"	*/
57 
58 #define	SYMREP	04000		/* symbols with doubled characters */
59 #define	ECSYM	(SYMREP|';')	/* ";;"		*/
60 #define	ANDFSYM	(SYMREP|'&')	/* "&&"		*/
61 #define	ORFSYM	(SYMREP|'|')	/* "||"		*/
62 #define	APPSYM	(SYMREP|'>')	/* ">>"		*/
63 #define	DOCSYM	(SYMREP|'<')	/* "<<"		*/
64 #define	SYMALT	01000		/* additional symbols */
65 #define	ECASYM	(SYMALT|'&')	/* ";&"		*/
66 #define	ECARSYM	(SYMALT|';')	/* ";;&"	*/
67 #define	EOFSYM	02000
68 #define	SYMFLG	0400		/* reserved symbols (see above) */
69 
70 /* arg to `cmd' */
71 #define	NLFLG	1		/* treat NL as ';' */
72 #define	MTFLG	2		/* empty cmd does not cause a syntax error */
73 #define	SEMIFLG	4		/* semi-colon after NL is ok */
74 #define	DOIOFLG	8		/* Parse I/O first in item() */
75 
76 /* for peekc */
77 #define	MARK	0x80000000
78 
79 /* odd chars */
80 #define	DQUOTE	'"'
81 #define	SQUOTE	'`'
82 #define	LITERAL	'\''
83 #define	DOLLAR	'$'
84 #define	ESCAPE	'\\'
85 #define	BRACE	'{'
86 #define	COMCHAR '#'
87 
88 /* wdset flags */
89 #define	KEYFLAG		1	/* var=value detected */
90 #define	IN_CASE		2	/* inside "case" - no keywords */
91