xref: /csrg-svn/bin/sh/parser.h (revision 69272)
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*69272Schristos  *	@(#)parser.h	8.3 (Berkeley) 05/04/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) */
2469090Sbostic #define VSTYPE	0x0f		/* type of variable substitution */
2569090Sbostic #define VSNUL	0x10		/* colon--treat the empty string as unset */
2669090Sbostic #define VSQUOTE 0x80		/* inside double quotes--suppress splitting */
2747140Sbostic 
2847140Sbostic /* values of VSTYPE field */
2969090Sbostic #define VSNORMAL	0x1		/* normal variable:  $var or ${var} */
3069090Sbostic #define VSMINUS		0x2		/* ${var-text} */
3169090Sbostic #define VSPLUS		0x3		/* ${var+text} */
3269090Sbostic #define VSQUESTION	0x4		/* ${var?message} */
3369090Sbostic #define VSASSIGN	0x5		/* ${var=text} */
3469090Sbostic #define VSTRIMLEFT	0x6		/* ${var#pattern} */
3569090Sbostic #define VSTRIMLEFTMAX	0x7		/* ${var##pattern} */
3669090Sbostic #define VSTRIMRIGHT	0x8		/* ${var%pattern} */
3769090Sbostic #define VSTRIMRIGHTMAX 	0x9		/* ${var%%pattern} */
3869090Sbostic #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 
51*69272Schristos union node *parsecmd __P((int));
52*69272Schristos void fixredir __P((union node *, const char *, int));
53*69272Schristos int goodname __P((char *));
54*69272Schristos char *getprompt __P((void *));
55