11.20Skre#	$NetBSD: nodetypes,v 1.20 2021/11/22 05:17:43 kre Exp $
21.4Sjtc# Copyright (c) 1991, 1993
31.4Sjtc#	The Regents of the University of California.  All rights reserved.
41.1Scgd#
51.1Scgd# This code is derived from software contributed to Berkeley by
61.1Scgd# Kenneth Almquist.
71.1Scgd#
81.1Scgd# Redistribution and use in source and binary forms, with or without
91.1Scgd# modification, are permitted provided that the following conditions
101.1Scgd# are met:
111.1Scgd# 1. Redistributions of source code must retain the above copyright
121.1Scgd#    notice, this list of conditions and the following disclaimer.
131.1Scgd# 2. Redistributions in binary form must reproduce the above copyright
141.1Scgd#    notice, this list of conditions and the following disclaimer in the
151.1Scgd#    documentation and/or other materials provided with the distribution.
161.12Sagc# 3. Neither the name of the University nor the names of its contributors
171.1Scgd#    may be used to endorse or promote products derived from this software
181.1Scgd#    without specific prior written permission.
191.1Scgd#
201.1Scgd# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
211.1Scgd# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
221.1Scgd# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
231.1Scgd# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
241.1Scgd# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
251.1Scgd# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
261.1Scgd# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
271.1Scgd# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
281.1Scgd# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
291.1Scgd# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
301.1Scgd# SUCH DAMAGE.
311.1Scgd#
321.8Schristos#	@(#)nodetypes	8.2 (Berkeley) 5/4/95
331.1Scgd
341.1Scgd# This file describes the nodes used in parse trees.  Unindented lines
351.1Scgd# contain a node type followed by a structure tag.  Subsequent indented
361.1Scgd# lines specify the fields of the structure.  Several node types can share
371.1Scgd# the same structure, in which case the fields of the structure should be
381.1Scgd# specified only once.
391.1Scgd#
401.1Scgd# A field of a structure is described by the name of the field followed
411.1Scgd# by a type.  The currently implemented types are:
421.1Scgd#	nodeptr - a pointer to a node
431.1Scgd#	nodelist - a pointer to a list of nodes
441.1Scgd#	string - a pointer to a nul terminated string
451.1Scgd#	int - an integer
461.1Scgd#	other - any type that can be copied by assignment
471.1Scgd#	temp - a field that doesn't have to be copied when the node is copied
481.1Scgd# The last two types should be followed by the text of a C declaration for
491.1Scgd# the field.
501.1Scgd
511.1ScgdNSEMI nbinary			# two commands separated by a semicolon
521.1Scgd	type	  int
531.1Scgd	ch1	  nodeptr		# the first child
541.1Scgd	ch2	  nodeptr		# the second child
551.1Scgd
561.1ScgdNCMD ncmd			# a simple command
571.1Scgd	type	  int
581.1Scgd	backgnd	  int			# set to run command in background
591.1Scgd	args	  nodeptr		# the arguments
601.1Scgd	redirect  nodeptr		# list of file redirections
611.16Skre	lineno	  int
621.1Scgd
631.1ScgdNPIPE npipe			# a pipeline
641.1Scgd	type	  int
651.1Scgd	backgnd	  int			# set to run pipeline in background
661.1Scgd	cmdlist	  nodelist		# the commands in the pipeline
671.1Scgd
681.11SchristosNREDIR nredir			# redirection (of a complex command)
691.1Scgd	type	  int
701.1Scgd	n	  nodeptr		# the command
711.1Scgd	redirect  nodeptr		# list of file redirections
721.1Scgd
731.1ScgdNBACKGND nredir			# run command in background
741.1ScgdNSUBSHELL nredir		# run command in a subshell
751.1Scgd
761.1ScgdNAND nbinary			# the && operator
771.1ScgdNOR nbinary			# the || operator
781.1Scgd
791.1ScgdNIF nif				# the if statement.  Elif clauses are handled
801.1Scgd	type	  int		    # using multiple if nodes.
811.1Scgd	test	  nodeptr		# if test
821.1Scgd	ifpart	  nodeptr		# then ifpart
831.1Scgd	elsepart  nodeptr		# else elsepart
841.1Scgd
851.1ScgdNWHILE nbinary			# the while statement.  First child is the test
861.1ScgdNUNTIL nbinary			# the until statement
871.1Scgd
881.1ScgdNFOR nfor			# the for statement
891.1Scgd	type	  int
901.1Scgd	args	  nodeptr		# for var in args
911.1Scgd	body	  nodeptr		# do body; done
921.1Scgd	var	  string		# the for variable
931.19Skre	lineno	  int
941.1Scgd
951.1ScgdNCASE ncase			# a case statement
961.1Scgd	type	  int
971.1Scgd	expr	  nodeptr		# the word to switch on
981.1Scgd	cases	  nodeptr		# the list of cases (NCLIST nodes)
991.16Skre	lineno	  int
1001.1Scgd
1011.14SkreNCLISTCONT nclist		# a case terminated by ';&' (fall through)
1021.1ScgdNCLIST nclist			# a case
1031.1Scgd	type	  int
1041.1Scgd	next	  nodeptr		# the next case in list
1051.1Scgd	pattern	  nodeptr		# list of patterns for this case
1061.1Scgd	body	  nodeptr		# code to execute for this case
1071.17Skre	lineno	  int
1081.1Scgd
1091.1Scgd
1101.1ScgdNDEFUN narg			# define a function.  The "next" field contains
1111.1Scgd				# the body of the function.
1121.1Scgd
1131.1ScgdNARG narg			# represents a word
1141.1Scgd	type	  int
1151.1Scgd	next	  nodeptr		# next word in list
1161.1Scgd	text	  string		# the text of the word
1171.1Scgd	backquote nodelist		# list of commands in back quotes
1181.17Skre	lineno	  int
1191.1Scgd
1201.1ScgdNTO nfile			# fd> fname
1211.10SchristosNCLOBBER nfile			# fd>| fname
1221.1ScgdNFROM nfile			# fd< fname
1231.9SchristosNFROMTO nfile			# fd<> fname
1241.1ScgdNAPPEND nfile			# fd>> fname
1251.1Scgd	type	  int
1261.1Scgd	next	  nodeptr		# next redirection in list
1271.1Scgd	fd	  int			# file descriptor being redirected
1281.1Scgd	fname	  nodeptr		# file name, in a NARG node
1291.1Scgd	expfname  temp	char *expfname	# actual file name
1301.1Scgd
1311.1ScgdNTOFD ndup			# fd<&dupfd
1321.1ScgdNFROMFD ndup			# fd>&dupfd
1331.1Scgd	type	  int
1341.1Scgd	next	  nodeptr		# next redirection in list
1351.1Scgd	fd	  int			# file descriptor being redirected
1361.1Scgd	dupfd	  int			# file descriptor to duplicate
1371.6Sjtc	vname	  nodeptr		# file name if fd>&$var
1381.8Schristos
1391.1Scgd
1401.1ScgdNHERE nhere			# fd<<\!
1411.1ScgdNXHERE nhere			# fd<<!
1421.1Scgd	type	  int
1431.1Scgd	next	  nodeptr		# next redirection in list
1441.1Scgd	fd	  int			# file descriptor being redirected
1451.1Scgd	doc	  nodeptr		# input to command (NARG node)
1461.20Skre	text	  temp  char *text	# expanded heredoc content
1471.4Sjtc
1481.4SjtcNNOT nnot			# ! command  (actually pipeline)
1491.15SkreNDNOT nnot			# ! ! pipeline (optimisation)
1501.13Sjoerg	type	  int
1511.13Sjoerg	com	  nodeptr
152