parser.h revision 1556
1226031Sstas/*- 2226031Sstas * Copyright (c) 1991, 1993 3226031Sstas * The Regents of the University of California. All rights reserved. 4226031Sstas * 5226031Sstas * This code is derived from software contributed to Berkeley by 6226031Sstas * Kenneth Almquist. 7226031Sstas * 8226031Sstas * Redistribution and use in source and binary forms, with or without 9226031Sstas * modification, are permitted provided that the following conditions 10226031Sstas * are met: 11226031Sstas * 1. Redistributions of source code must retain the above copyright 12226031Sstas * notice, this list of conditions and the following disclaimer. 13226031Sstas * 2. Redistributions in binary form must reproduce the above copyright 14226031Sstas * notice, this list of conditions and the following disclaimer in the 15226128Sstas * documentation and/or other materials provided with the distribution. 16226031Sstas * 3. All advertising materials mentioning features or use of this software 17226031Sstas * must display the following acknowledgement: 18226031Sstas * This product includes software developed by the University of 19226031Sstas * California, Berkeley and its contributors. 20226031Sstas * 4. Neither the name of the University nor the names of its contributors 21226031Sstas * may be used to endorse or promote products derived from this software 22226031Sstas * without specific prior written permission. 23226031Sstas * 24226031Sstas * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25226031Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26226031Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27226031Sstas * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28226031Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29226031Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30226031Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31226031Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32226031Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33226031Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34226031Sstas * SUCH DAMAGE. 35226031Sstas * 36226031Sstas * @(#)parser.h 8.1 (Berkeley) 5/31/93 37226031Sstas */ 38226031Sstas 39226031Sstas/* control characters in argument strings */ 40226031Sstas#define CTLESC '\201' 41226031Sstas#define CTLVAR '\202' 42226031Sstas#define CTLENDVAR '\203' 43226031Sstas#define CTLBACKQ '\204' 44226031Sstas#define CTLQUOTE 01 /* ored with CTLBACKQ code if in quotes */ 45226031Sstas/* CTLBACKQ | CTLQUOTE == '\205' */ 46226031Sstas#define CTLARI '\206' 47226031Sstas#define CTLENDARI '\207' 48226031Sstas 49226031Sstas/* variable substitution byte (follows CTLVAR) */ 50226031Sstas#define VSTYPE 07 /* type of variable substitution */ 51226031Sstas#define VSNUL 040 /* colon--treat the empty string as unset */ 52226031Sstas#define VSQUOTE 0100 /* inside double quotes--suppress splitting */ 53226031Sstas 54226031Sstas/* values of VSTYPE field */ 55226031Sstas#define VSNORMAL 1 /* normal variable: $var or ${var} */ 56226031Sstas#define VSMINUS 2 /* ${var-text} */ 57226031Sstas#define VSPLUS 3 /* ${var+text} */ 58226031Sstas#define VSQUESTION 4 /* ${var?message} */ 59226031Sstas#define VSASSIGN 5 /* ${var=text} */ 60226031Sstas 61226031Sstas 62226031Sstas/* 63226031Sstas * NEOF is returned by parsecmd when it encounters an end of file. It 64226031Sstas * must be distinct from NULL, so we use the address of a variable that 65226031Sstas * happens to be handy. 66226031Sstas */ 67226031Sstasextern int tokpushback; 68226031Sstas#define NEOF ((union node *)&tokpushback) 69226031Sstasextern int whichprompt; /* 1 == PS1, 2 == PS2 */ 70226031Sstas 71226031Sstas 72226031Sstas#ifdef __STDC__ 73226031Sstasunion node *parsecmd(int); 74226031Sstasint goodname(char *); 75226031Sstaschar *getprompt(void *); 76226031Sstas#else 77226031Sstasunion node *parsecmd(); 78226031Sstasint goodname(); 79226031Sstaschar *getprompt(); 80226031Sstas#endif 81226031Sstas