147140Sbostic /*- 260698Sbostic * Copyright (c) 1991, 1993 360698Sbostic * The Regents of the University of California. All rights reserved. 447140Sbostic * 547140Sbostic * This code is derived from software contributed to Berkeley by 647140Sbostic * Kenneth Almquist. 747140Sbostic * 847140Sbostic * %sccs.include.redist.c% 947140Sbostic * 10*69090Sbostic * @(#)parser.h 8.2 (Berkeley) 04/28/95 1147140Sbostic */ 1247140Sbostic 1347140Sbostic /* control characters in argument strings */ 1447140Sbostic #define CTLESC '\201' 1547140Sbostic #define CTLVAR '\202' 1647140Sbostic #define CTLENDVAR '\203' 1747140Sbostic #define CTLBACKQ '\204' 1847140Sbostic #define CTLQUOTE 01 /* ored with CTLBACKQ code if in quotes */ 1953303Smarc /* CTLBACKQ | CTLQUOTE == '\205' */ 2053303Smarc #define CTLARI '\206' 2153303Smarc #define CTLENDARI '\207' 2247140Sbostic 2347140Sbostic /* variable substitution byte (follows CTLVAR) */ 24*69090Sbostic #define VSTYPE 0x0f /* type of variable substitution */ 25*69090Sbostic #define VSNUL 0x10 /* colon--treat the empty string as unset */ 26*69090Sbostic #define VSQUOTE 0x80 /* inside double quotes--suppress splitting */ 2747140Sbostic 2847140Sbostic /* values of VSTYPE field */ 29*69090Sbostic #define VSNORMAL 0x1 /* normal variable: $var or ${var} */ 30*69090Sbostic #define VSMINUS 0x2 /* ${var-text} */ 31*69090Sbostic #define VSPLUS 0x3 /* ${var+text} */ 32*69090Sbostic #define VSQUESTION 0x4 /* ${var?message} */ 33*69090Sbostic #define VSASSIGN 0x5 /* ${var=text} */ 34*69090Sbostic #define VSTRIMLEFT 0x6 /* ${var#pattern} */ 35*69090Sbostic #define VSTRIMLEFTMAX 0x7 /* ${var##pattern} */ 36*69090Sbostic #define VSTRIMRIGHT 0x8 /* ${var%pattern} */ 37*69090Sbostic #define VSTRIMRIGHTMAX 0x9 /* ${var%%pattern} */ 38*69090Sbostic #define VSLENGTH 0xa /* ${#var} */ 3947140Sbostic 4047140Sbostic 4147140Sbostic /* 4247140Sbostic * NEOF is returned by parsecmd when it encounters an end of file. It 4347140Sbostic * must be distinct from NULL, so we use the address of a variable that 4447140Sbostic * happens to be handy. 4547140Sbostic */ 4647140Sbostic extern int tokpushback; 4747140Sbostic #define NEOF ((union node *)&tokpushback) 4854326Smarc extern int whichprompt; /* 1 == PS1, 2 == PS2 */ 4947140Sbostic 5047140Sbostic 5147140Sbostic #ifdef __STDC__ 5247140Sbostic union node *parsecmd(int); 5347140Sbostic int goodname(char *); 5454326Smarc char *getprompt(void *); 5547140Sbostic #else 5647140Sbostic union node *parsecmd(); 5747140Sbostic int goodname(); 5854326Smarc char *getprompt(); 5947140Sbostic #endif 60