nodetypes revision 66612
11556Srgrimes#
21556Srgrimes# Copyright (c) 1991, 1993
31556Srgrimes#	The Regents of the University of California.  All rights reserved.
41556Srgrimes#
51556Srgrimes# This code is derived from software contributed to Berkeley by
61556Srgrimes# Kenneth Almquist.
71556Srgrimes#
81556Srgrimes# Redistribution and use in source and binary forms, with or without
91556Srgrimes# modification, are permitted provided that the following conditions
101556Srgrimes# are met:
111556Srgrimes# 1. Redistributions of source code must retain the above copyright
121556Srgrimes#    notice, this list of conditions and the following disclaimer.
131556Srgrimes# 2. Redistributions in binary form must reproduce the above copyright
141556Srgrimes#    notice, this list of conditions and the following disclaimer in the
151556Srgrimes#    documentation and/or other materials provided with the distribution.
161556Srgrimes# 3. All advertising materials mentioning features or use of this software
171556Srgrimes#    must display the following acknowledgement:
181556Srgrimes#	This product includes software developed by the University of
191556Srgrimes#	California, Berkeley and its contributors.
201556Srgrimes# 4. Neither the name of the University nor the names of its contributors
211556Srgrimes#    may be used to endorse or promote products derived from this software
221556Srgrimes#    without specific prior written permission.
231556Srgrimes#
241556Srgrimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251556Srgrimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261556Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271556Srgrimes# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281556Srgrimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291556Srgrimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301556Srgrimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311556Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321556Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331556Srgrimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341556Srgrimes# SUCH DAMAGE.
351556Srgrimes#
3617987Speter#	@(#)nodetypes	8.2 (Berkeley) 5/4/95
3750471Speter# $FreeBSD: head/bin/sh/nodetypes 66612 2000-10-03 23:13:14Z brian $
381556Srgrimes
391556Srgrimes# This file describes the nodes used in parse trees.  Unindented lines
401556Srgrimes# contain a node type followed by a structure tag.  Subsequent indented
411556Srgrimes# lines specify the fields of the structure.  Several node types can share
421556Srgrimes# the same structure, in which case the fields of the structure should be
431556Srgrimes# specified only once.
441556Srgrimes#
451556Srgrimes# A field of a structure is described by the name of the field followed
461556Srgrimes# by a type.  The currently implemented types are:
471556Srgrimes#	nodeptr - a pointer to a node
481556Srgrimes#	nodelist - a pointer to a list of nodes
491556Srgrimes#	string - a pointer to a nul terminated string
501556Srgrimes#	int - an integer
511556Srgrimes#	other - any type that can be copied by assignment
521556Srgrimes#	temp - a field that doesn't have to be copied when the node is copied
531556Srgrimes# The last two types should be followed by the text of a C declaration for
541556Srgrimes# the field.
551556Srgrimes
561556SrgrimesNSEMI nbinary			# two commands separated by a semicolon
571556Srgrimes	type	  int
581556Srgrimes	ch1	  nodeptr		# the first child
591556Srgrimes	ch2	  nodeptr		# the second child
601556Srgrimes
611556SrgrimesNCMD ncmd			# a simple command
621556Srgrimes	type	  int
631556Srgrimes	backgnd	  int			# set to run command in background
641556Srgrimes	args	  nodeptr		# the arguments
651556Srgrimes	redirect  nodeptr		# list of file redirections
661556Srgrimes
671556SrgrimesNPIPE npipe			# a pipeline
681556Srgrimes	type	  int
691556Srgrimes	backgnd	  int			# set to run pipeline in background
701556Srgrimes	cmdlist	  nodelist		# the commands in the pipeline
711556Srgrimes
721556SrgrimesNREDIR nredir			# redirection (of a compex command)
731556Srgrimes	type	  int
741556Srgrimes	n	  nodeptr		# the command
751556Srgrimes	redirect  nodeptr		# list of file redirections
761556Srgrimes
771556SrgrimesNBACKGND nredir			# run command in background
781556SrgrimesNSUBSHELL nredir		# run command in a subshell
791556Srgrimes
801556SrgrimesNAND nbinary			# the && operator
811556SrgrimesNOR nbinary			# the || operator
821556Srgrimes
831556SrgrimesNIF nif				# the if statement.  Elif clauses are handled
841556Srgrimes	type	  int		    # using multiple if nodes.
851556Srgrimes	test	  nodeptr		# if test
861556Srgrimes	ifpart	  nodeptr		# then ifpart
871556Srgrimes	elsepart  nodeptr		# else elsepart
881556Srgrimes
891556SrgrimesNWHILE nbinary			# the while statement.  First child is the test
901556SrgrimesNUNTIL nbinary			# the until statement
911556Srgrimes
921556SrgrimesNFOR nfor			# the for statement
931556Srgrimes	type	  int
941556Srgrimes	args	  nodeptr		# for var in args
951556Srgrimes	body	  nodeptr		# do body; done
961556Srgrimes	var	  string		# the for variable
971556Srgrimes
981556SrgrimesNCASE ncase			# a case statement
991556Srgrimes	type	  int
1001556Srgrimes	expr	  nodeptr		# the word to switch on
1011556Srgrimes	cases	  nodeptr		# the list of cases (NCLIST nodes)
1021556Srgrimes
1031556SrgrimesNCLIST nclist			# a case
1041556Srgrimes	type	  int
1051556Srgrimes	next	  nodeptr		# the next case in list
1061556Srgrimes	pattern	  nodeptr		# list of patterns for this case
1071556Srgrimes	body	  nodeptr		# code to execute for this case
1081556Srgrimes
1091556Srgrimes
1101556SrgrimesNDEFUN narg			# define a function.  The "next" field contains
1111556Srgrimes				# the body of the function.
1121556Srgrimes
1131556SrgrimesNARG narg			# represents a word
1141556Srgrimes	type	  int
1151556Srgrimes	next	  nodeptr		# next word in list
1161556Srgrimes	text	  string		# the text of the word
1171556Srgrimes	backquote nodelist		# list of commands in back quotes
1181556Srgrimes
1191556SrgrimesNTO nfile			# fd> fname
1201556SrgrimesNFROM nfile			# fd< fname
12166612SbrianNFROMTO nfile			# fd<> fname
1221556SrgrimesNAPPEND nfile			# fd>> fname
1231556Srgrimes	type	  int
1241556Srgrimes	next	  nodeptr		# next redirection in list
1251556Srgrimes	fd	  int			# file descriptor being redirected
1261556Srgrimes	fname	  nodeptr		# file name, in a NARG node
1271556Srgrimes	expfname  temp	char *expfname	# actual file name
1281556Srgrimes
1291556SrgrimesNTOFD ndup			# fd<&dupfd
1301556SrgrimesNFROMFD ndup			# fd>&dupfd
1311556Srgrimes	type	  int
1321556Srgrimes	next	  nodeptr		# next redirection in list
1331556Srgrimes	fd	  int			# file descriptor being redirected
1341556Srgrimes	dupfd	  int			# file descriptor to duplicate
13517987Speter	vname	  nodeptr		# file name if fd>&$var
1361556Srgrimes
13717987Speter
1381556SrgrimesNHERE nhere			# fd<<\!
1391556SrgrimesNXHERE nhere			# fd<<!
1401556Srgrimes	type	  int
1411556Srgrimes	next	  nodeptr		# next redirection in list
1421556Srgrimes	fd	  int			# file descriptor being redirected
1431556Srgrimes	doc	  nodeptr		# input to command (NARG node)
1441556Srgrimes
1451556SrgrimesNNOT nnot			# ! command  (actually pipeline)
1461556Srgrimes	type	int
1471556Srgrimes	com	nodeptr
148