1139969Simp#-
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# 4. Neither the name of the University nor the names of its contributors
171556Srgrimes#    may be used to endorse or promote products derived from this software
181556Srgrimes#    without specific prior written permission.
191556Srgrimes#
201556Srgrimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
211556Srgrimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
221556Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
231556Srgrimes# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
241556Srgrimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
251556Srgrimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
261556Srgrimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
271556Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
281556Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
291556Srgrimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
301556Srgrimes# SUCH DAMAGE.
311556Srgrimes#
3217987Speter#	@(#)nodetypes	8.2 (Berkeley) 5/4/95
3350471Speter# $FreeBSD$
341556Srgrimes
351556Srgrimes# This file describes the nodes used in parse trees.  Unindented lines
361556Srgrimes# contain a node type followed by a structure tag.  Subsequent indented
371556Srgrimes# lines specify the fields of the structure.  Several node types can share
381556Srgrimes# the same structure, in which case the fields of the structure should be
391556Srgrimes# specified only once.
401556Srgrimes#
411556Srgrimes# A field of a structure is described by the name of the field followed
421556Srgrimes# by a type.  The currently implemented types are:
431556Srgrimes#	nodeptr - a pointer to a node
441556Srgrimes#	nodelist - a pointer to a list of nodes
451556Srgrimes#	string - a pointer to a nul terminated string
461556Srgrimes#	int - an integer
471556Srgrimes#	other - any type that can be copied by assignment
481556Srgrimes#	temp - a field that doesn't have to be copied when the node is copied
491556Srgrimes# The last two types should be followed by the text of a C declaration for
501556Srgrimes# the field.
511556Srgrimes
521556SrgrimesNSEMI nbinary			# two commands separated by a semicolon
531556Srgrimes	type	  int
541556Srgrimes	ch1	  nodeptr		# the first child
551556Srgrimes	ch2	  nodeptr		# the second child
561556Srgrimes
571556SrgrimesNCMD ncmd			# a simple command
581556Srgrimes	type	  int
591556Srgrimes	args	  nodeptr		# the arguments
601556Srgrimes	redirect  nodeptr		# list of file redirections
611556Srgrimes
621556SrgrimesNPIPE npipe			# a pipeline
631556Srgrimes	type	  int
641556Srgrimes	backgnd	  int			# set to run pipeline in background
651556Srgrimes	cmdlist	  nodelist		# the commands in the pipeline
661556Srgrimes
671556SrgrimesNREDIR nredir			# redirection (of a compex command)
681556Srgrimes	type	  int
691556Srgrimes	n	  nodeptr		# the command
701556Srgrimes	redirect  nodeptr		# list of file redirections
711556Srgrimes
721556SrgrimesNBACKGND nredir			# run command in background
731556SrgrimesNSUBSHELL nredir		# run command in a subshell
741556Srgrimes
751556SrgrimesNAND nbinary			# the && operator
761556SrgrimesNOR nbinary			# the || operator
771556Srgrimes
781556SrgrimesNIF nif				# the if statement.  Elif clauses are handled
791556Srgrimes	type	  int		    # using multiple if nodes.
801556Srgrimes	test	  nodeptr		# if test
811556Srgrimes	ifpart	  nodeptr		# then ifpart
821556Srgrimes	elsepart  nodeptr		# else elsepart
831556Srgrimes
841556SrgrimesNWHILE nbinary			# the while statement.  First child is the test
851556SrgrimesNUNTIL nbinary			# the until statement
861556Srgrimes
871556SrgrimesNFOR nfor			# the for statement
881556Srgrimes	type	  int
891556Srgrimes	args	  nodeptr		# for var in args
901556Srgrimes	body	  nodeptr		# do body; done
911556Srgrimes	var	  string		# the for variable
921556Srgrimes
931556SrgrimesNCASE ncase			# a case statement
941556Srgrimes	type	  int
951556Srgrimes	expr	  nodeptr		# the word to switch on
961556Srgrimes	cases	  nodeptr		# the list of cases (NCLIST nodes)
971556Srgrimes
98223186SjillesNCLIST nclist			# a case ending with ;;
991556Srgrimes	type	  int
1001556Srgrimes	next	  nodeptr		# the next case in list
1011556Srgrimes	pattern	  nodeptr		# list of patterns for this case
1021556Srgrimes	body	  nodeptr		# code to execute for this case
1031556Srgrimes
104223186SjillesNCLISTFALLTHRU nclist		# a case ending with ;&
1051556Srgrimes
1061556SrgrimesNDEFUN narg			# define a function.  The "next" field contains
1071556Srgrimes				# the body of the function.
1081556Srgrimes
1091556SrgrimesNARG narg			# represents a word
1101556Srgrimes	type	  int
1111556Srgrimes	next	  nodeptr		# next word in list
1121556Srgrimes	text	  string		# the text of the word
1131556Srgrimes	backquote nodelist		# list of commands in back quotes
1141556Srgrimes
1151556SrgrimesNTO nfile			# fd> fname
1161556SrgrimesNFROM nfile			# fd< fname
11766612SbrianNFROMTO nfile			# fd<> fname
1181556SrgrimesNAPPEND nfile			# fd>> fname
11996922StjrNCLOBBER nfile			# fd>| fname
1201556Srgrimes	type	  int
1211556Srgrimes	next	  nodeptr		# next redirection in list
1221556Srgrimes	fd	  int			# file descriptor being redirected
1231556Srgrimes	fname	  nodeptr		# file name, in a NARG node
1241556Srgrimes	expfname  temp	char *expfname	# actual file name
1251556Srgrimes
1261556SrgrimesNTOFD ndup			# fd<&dupfd
1271556SrgrimesNFROMFD ndup			# fd>&dupfd
1281556Srgrimes	type	  int
1291556Srgrimes	next	  nodeptr		# next redirection in list
1301556Srgrimes	fd	  int			# file descriptor being redirected
1311556Srgrimes	dupfd	  int			# file descriptor to duplicate
13217987Speter	vname	  nodeptr		# file name if fd>&$var
1331556Srgrimes
13417987Speter
1351556SrgrimesNHERE nhere			# fd<<\!
1361556SrgrimesNXHERE nhere			# fd<<!
1371556Srgrimes	type	  int
1381556Srgrimes	next	  nodeptr		# next redirection in list
1391556Srgrimes	fd	  int			# file descriptor being redirected
1401556Srgrimes	doc	  nodeptr		# input to command (NARG node)
1411556Srgrimes
1421556SrgrimesNNOT nnot			# ! command  (actually pipeline)
1431556Srgrimes	type	int
1441556Srgrimes	com	nodeptr
145