xref: /freebsd/bin/sh/nodetypes (revision 90aea514c6249118e880d75972d063362f4bf492)
19ddb49cbSWarner Losh#-
24b88c807SRodney W. Grimes# Copyright (c) 1991, 1993
34b88c807SRodney W. Grimes#	The Regents of the University of California.  All rights reserved.
44b88c807SRodney W. Grimes#
54b88c807SRodney W. Grimes# This code is derived from software contributed to Berkeley by
64b88c807SRodney W. Grimes# Kenneth Almquist.
74b88c807SRodney W. Grimes#
84b88c807SRodney W. Grimes# Redistribution and use in source and binary forms, with or without
94b88c807SRodney W. Grimes# modification, are permitted provided that the following conditions
104b88c807SRodney W. Grimes# are met:
114b88c807SRodney W. Grimes# 1. Redistributions of source code must retain the above copyright
124b88c807SRodney W. Grimes#    notice, this list of conditions and the following disclaimer.
134b88c807SRodney W. Grimes# 2. Redistributions in binary form must reproduce the above copyright
144b88c807SRodney W. Grimes#    notice, this list of conditions and the following disclaimer in the
154b88c807SRodney W. Grimes#    documentation and/or other materials provided with the distribution.
16fbbd9655SWarner Losh# 3. Neither the name of the University nor the names of its contributors
174b88c807SRodney W. Grimes#    may be used to endorse or promote products derived from this software
184b88c807SRodney W. Grimes#    without specific prior written permission.
194b88c807SRodney W. Grimes#
204b88c807SRodney W. Grimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
214b88c807SRodney W. Grimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
224b88c807SRodney W. Grimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
234b88c807SRodney W. Grimes# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
244b88c807SRodney W. Grimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
254b88c807SRodney W. Grimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
264b88c807SRodney W. Grimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
274b88c807SRodney W. Grimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
284b88c807SRodney W. Grimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
294b88c807SRodney W. Grimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
304b88c807SRodney W. Grimes# SUCH DAMAGE.
314b88c807SRodney W. Grimes
324b88c807SRodney W. Grimes# This file describes the nodes used in parse trees.  Unindented lines
334b88c807SRodney W. Grimes# contain a node type followed by a structure tag.  Subsequent indented
344b88c807SRodney W. Grimes# lines specify the fields of the structure.  Several node types can share
354b88c807SRodney W. Grimes# the same structure, in which case the fields of the structure should be
364b88c807SRodney W. Grimes# specified only once.
374b88c807SRodney W. Grimes#
384b88c807SRodney W. Grimes# A field of a structure is described by the name of the field followed
394b88c807SRodney W. Grimes# by a type.  The currently implemented types are:
404b88c807SRodney W. Grimes#	nodeptr - a pointer to a node
414b88c807SRodney W. Grimes#	nodelist - a pointer to a list of nodes
424b88c807SRodney W. Grimes#	string - a pointer to a nul terminated string
434b88c807SRodney W. Grimes#	int - an integer
444b88c807SRodney W. Grimes#	other - any type that can be copied by assignment
454b88c807SRodney W. Grimes#	temp - a field that doesn't have to be copied when the node is copied
464b88c807SRodney W. Grimes# The last two types should be followed by the text of a C declaration for
474b88c807SRodney W. Grimes# the field.
484b88c807SRodney W. Grimes
494b88c807SRodney W. GrimesNSEMI nbinary			# two commands separated by a semicolon
504b88c807SRodney W. Grimes	type	  int
514b88c807SRodney W. Grimes	ch1	  nodeptr		# the first child
524b88c807SRodney W. Grimes	ch2	  nodeptr		# the second child
534b88c807SRodney W. Grimes
544b88c807SRodney W. GrimesNCMD ncmd			# a simple command
554b88c807SRodney W. Grimes	type	  int
564b88c807SRodney W. Grimes	args	  nodeptr		# the arguments
574b88c807SRodney W. Grimes	redirect  nodeptr		# list of file redirections
584b88c807SRodney W. Grimes
594b88c807SRodney W. GrimesNPIPE npipe			# a pipeline
604b88c807SRodney W. Grimes	type	  int
614b88c807SRodney W. Grimes	backgnd	  int			# set to run pipeline in background
624b88c807SRodney W. Grimes	cmdlist	  nodelist		# the commands in the pipeline
634b88c807SRodney W. Grimes
64*48556dffSElyes HAOUASNREDIR nredir			# redirection (of a complex command)
654b88c807SRodney W. Grimes	type	  int
664b88c807SRodney W. Grimes	n	  nodeptr		# the command
674b88c807SRodney W. Grimes	redirect  nodeptr		# list of file redirections
684b88c807SRodney W. Grimes
694b88c807SRodney W. GrimesNBACKGND nredir			# run command in background
704b88c807SRodney W. GrimesNSUBSHELL nredir		# run command in a subshell
714b88c807SRodney W. Grimes
724b88c807SRodney W. GrimesNAND nbinary			# the && operator
734b88c807SRodney W. GrimesNOR nbinary			# the || operator
744b88c807SRodney W. Grimes
754b88c807SRodney W. GrimesNIF nif				# the if statement.  Elif clauses are handled
764b88c807SRodney W. Grimes	type	  int		    # using multiple if nodes.
774b88c807SRodney W. Grimes	test	  nodeptr		# if test
784b88c807SRodney W. Grimes	ifpart	  nodeptr		# then ifpart
794b88c807SRodney W. Grimes	elsepart  nodeptr		# else elsepart
804b88c807SRodney W. Grimes
814b88c807SRodney W. GrimesNWHILE nbinary			# the while statement.  First child is the test
824b88c807SRodney W. GrimesNUNTIL nbinary			# the until statement
834b88c807SRodney W. Grimes
844b88c807SRodney W. GrimesNFOR nfor			# the for statement
854b88c807SRodney W. Grimes	type	  int
864b88c807SRodney W. Grimes	args	  nodeptr		# for var in args
874b88c807SRodney W. Grimes	body	  nodeptr		# do body; done
884b88c807SRodney W. Grimes	var	  string		# the for variable
894b88c807SRodney W. Grimes
904b88c807SRodney W. GrimesNCASE ncase			# a case statement
914b88c807SRodney W. Grimes	type	  int
924b88c807SRodney W. Grimes	expr	  nodeptr		# the word to switch on
934b88c807SRodney W. Grimes	cases	  nodeptr		# the list of cases (NCLIST nodes)
944b88c807SRodney W. Grimes
95c9afaa63SJilles TjoelkerNCLIST nclist			# a case ending with ;;
964b88c807SRodney W. Grimes	type	  int
974b88c807SRodney W. Grimes	next	  nodeptr		# the next case in list
984b88c807SRodney W. Grimes	pattern	  nodeptr		# list of patterns for this case
994b88c807SRodney W. Grimes	body	  nodeptr		# code to execute for this case
1004b88c807SRodney W. Grimes
101c9afaa63SJilles TjoelkerNCLISTFALLTHRU nclist		# a case ending with ;&
1024b88c807SRodney W. Grimes
1034b88c807SRodney W. GrimesNDEFUN narg			# define a function.  The "next" field contains
1044b88c807SRodney W. Grimes				# the body of the function.
1054b88c807SRodney W. Grimes
1064b88c807SRodney W. GrimesNARG narg			# represents a word
1074b88c807SRodney W. Grimes	type	  int
1084b88c807SRodney W. Grimes	next	  nodeptr		# next word in list
1094b88c807SRodney W. Grimes	text	  string		# the text of the word
1104b88c807SRodney W. Grimes	backquote nodelist		# list of commands in back quotes
1114b88c807SRodney W. Grimes
1124b88c807SRodney W. GrimesNTO nfile			# fd> fname
1134b88c807SRodney W. GrimesNFROM nfile			# fd< fname
1144682f420SBrian SomersNFROMTO nfile			# fd<> fname
1154b88c807SRodney W. GrimesNAPPEND nfile			# fd>> fname
1161a958c66STim J. RobbinsNCLOBBER nfile			# fd>| fname
1174b88c807SRodney W. Grimes	type	  int
1184b88c807SRodney W. Grimes	fd	  int			# file descriptor being redirected
119fd692a70SJilles Tjoelker	next	  nodeptr		# next redirection in list
1204b88c807SRodney W. Grimes	fname	  nodeptr		# file name, in a NARG node
1214b88c807SRodney W. Grimes	expfname  temp	char *expfname	# actual file name
1224b88c807SRodney W. Grimes
1234b88c807SRodney W. GrimesNTOFD ndup			# fd<&dupfd
1244b88c807SRodney W. GrimesNFROMFD ndup			# fd>&dupfd
1254b88c807SRodney W. Grimes	type	  int
1264b88c807SRodney W. Grimes	fd	  int			# file descriptor being redirected
127fd692a70SJilles Tjoelker	next	  nodeptr		# next redirection in list
1284b88c807SRodney W. Grimes	dupfd	  int			# file descriptor to duplicate
129aa9caaf6SPeter Wemm	vname	  nodeptr		# file name if fd>&$var
130aa9caaf6SPeter Wemm
1314b88c807SRodney W. Grimes
1324b88c807SRodney W. GrimesNHERE nhere			# fd<<\!
1334b88c807SRodney W. GrimesNXHERE nhere			# fd<<!
1344b88c807SRodney W. Grimes	type	  int
1354b88c807SRodney W. Grimes	fd	  int			# file descriptor being redirected
136fd692a70SJilles Tjoelker	next	  nodeptr		# next redirection in list
1374b88c807SRodney W. Grimes	doc	  nodeptr		# input to command (NARG node)
138781bfb5aSJilles Tjoelker	expdoc    temp	const char *expdoc	# actual document (for NXHERE)
1394b88c807SRodney W. Grimes
1404b88c807SRodney W. GrimesNNOT nnot			# ! command  (actually pipeline)
1414b88c807SRodney W. Grimes	type	int
1424b88c807SRodney W. Grimes	com	nodeptr
143