xref: /minix3/bin/sh/nodetypes (revision d90bee97498b3043241050f61aed100786c59df4)
1*d90bee97SLionel Sambuc#	$NetBSD: nodetypes,v 1.13 2009/05/26 07:30:51 joerg Exp $
2*d90bee97SLionel Sambuc# Copyright (c) 1991, 1993
3*d90bee97SLionel Sambuc#	The Regents of the University of California.  All rights reserved.
4*d90bee97SLionel Sambuc#
5*d90bee97SLionel Sambuc# This code is derived from software contributed to Berkeley by
6*d90bee97SLionel Sambuc# Kenneth Almquist.
7*d90bee97SLionel Sambuc#
8*d90bee97SLionel Sambuc# Redistribution and use in source and binary forms, with or without
9*d90bee97SLionel Sambuc# modification, are permitted provided that the following conditions
10*d90bee97SLionel Sambuc# are met:
11*d90bee97SLionel Sambuc# 1. Redistributions of source code must retain the above copyright
12*d90bee97SLionel Sambuc#    notice, this list of conditions and the following disclaimer.
13*d90bee97SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright
14*d90bee97SLionel Sambuc#    notice, this list of conditions and the following disclaimer in the
15*d90bee97SLionel Sambuc#    documentation and/or other materials provided with the distribution.
16*d90bee97SLionel Sambuc# 3. Neither the name of the University nor the names of its contributors
17*d90bee97SLionel Sambuc#    may be used to endorse or promote products derived from this software
18*d90bee97SLionel Sambuc#    without specific prior written permission.
19*d90bee97SLionel Sambuc#
20*d90bee97SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21*d90bee97SLionel Sambuc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*d90bee97SLionel Sambuc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*d90bee97SLionel Sambuc# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24*d90bee97SLionel Sambuc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*d90bee97SLionel Sambuc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*d90bee97SLionel Sambuc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*d90bee97SLionel Sambuc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*d90bee97SLionel Sambuc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*d90bee97SLionel Sambuc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*d90bee97SLionel Sambuc# SUCH DAMAGE.
31*d90bee97SLionel Sambuc#
32*d90bee97SLionel Sambuc#	@(#)nodetypes	8.2 (Berkeley) 5/4/95
33*d90bee97SLionel Sambuc
34*d90bee97SLionel Sambuc# This file describes the nodes used in parse trees.  Unindented lines
35*d90bee97SLionel Sambuc# contain a node type followed by a structure tag.  Subsequent indented
36*d90bee97SLionel Sambuc# lines specify the fields of the structure.  Several node types can share
37*d90bee97SLionel Sambuc# the same structure, in which case the fields of the structure should be
38*d90bee97SLionel Sambuc# specified only once.
39*d90bee97SLionel Sambuc#
40*d90bee97SLionel Sambuc# A field of a structure is described by the name of the field followed
41*d90bee97SLionel Sambuc# by a type.  The currently implemented types are:
42*d90bee97SLionel Sambuc#	nodeptr - a pointer to a node
43*d90bee97SLionel Sambuc#	nodelist - a pointer to a list of nodes
44*d90bee97SLionel Sambuc#	string - a pointer to a nul terminated string
45*d90bee97SLionel Sambuc#	int - an integer
46*d90bee97SLionel Sambuc#	other - any type that can be copied by assignment
47*d90bee97SLionel Sambuc#	temp - a field that doesn't have to be copied when the node is copied
48*d90bee97SLionel Sambuc# The last two types should be followed by the text of a C declaration for
49*d90bee97SLionel Sambuc# the field.
50*d90bee97SLionel Sambuc
51*d90bee97SLionel SambucNSEMI nbinary			# two commands separated by a semicolon
52*d90bee97SLionel Sambuc	type	  int
53*d90bee97SLionel Sambuc	ch1	  nodeptr		# the first child
54*d90bee97SLionel Sambuc	ch2	  nodeptr		# the second child
55*d90bee97SLionel Sambuc
56*d90bee97SLionel SambucNCMD ncmd			# a simple command
57*d90bee97SLionel Sambuc	type	  int
58*d90bee97SLionel Sambuc	backgnd	  int			# set to run command in background
59*d90bee97SLionel Sambuc	args	  nodeptr		# the arguments
60*d90bee97SLionel Sambuc	redirect  nodeptr		# list of file redirections
61*d90bee97SLionel Sambuc
62*d90bee97SLionel SambucNPIPE npipe			# a pipeline
63*d90bee97SLionel Sambuc	type	  int
64*d90bee97SLionel Sambuc	backgnd	  int			# set to run pipeline in background
65*d90bee97SLionel Sambuc	cmdlist	  nodelist		# the commands in the pipeline
66*d90bee97SLionel Sambuc
67*d90bee97SLionel SambucNREDIR nredir			# redirection (of a complex command)
68*d90bee97SLionel Sambuc	type	  int
69*d90bee97SLionel Sambuc	n	  nodeptr		# the command
70*d90bee97SLionel Sambuc	redirect  nodeptr		# list of file redirections
71*d90bee97SLionel Sambuc
72*d90bee97SLionel SambucNBACKGND nredir			# run command in background
73*d90bee97SLionel SambucNSUBSHELL nredir		# run command in a subshell
74*d90bee97SLionel Sambuc
75*d90bee97SLionel SambucNAND nbinary			# the && operator
76*d90bee97SLionel SambucNOR nbinary			# the || operator
77*d90bee97SLionel Sambuc
78*d90bee97SLionel SambucNIF nif				# the if statement.  Elif clauses are handled
79*d90bee97SLionel Sambuc	type	  int		    # using multiple if nodes.
80*d90bee97SLionel Sambuc	test	  nodeptr		# if test
81*d90bee97SLionel Sambuc	ifpart	  nodeptr		# then ifpart
82*d90bee97SLionel Sambuc	elsepart  nodeptr		# else elsepart
83*d90bee97SLionel Sambuc
84*d90bee97SLionel SambucNWHILE nbinary			# the while statement.  First child is the test
85*d90bee97SLionel SambucNUNTIL nbinary			# the until statement
86*d90bee97SLionel Sambuc
87*d90bee97SLionel SambucNFOR nfor			# the for statement
88*d90bee97SLionel Sambuc	type	  int
89*d90bee97SLionel Sambuc	args	  nodeptr		# for var in args
90*d90bee97SLionel Sambuc	body	  nodeptr		# do body; done
91*d90bee97SLionel Sambuc	var	  string		# the for variable
92*d90bee97SLionel Sambuc
93*d90bee97SLionel SambucNCASE ncase			# a case statement
94*d90bee97SLionel Sambuc	type	  int
95*d90bee97SLionel Sambuc	expr	  nodeptr		# the word to switch on
96*d90bee97SLionel Sambuc	cases	  nodeptr		# the list of cases (NCLIST nodes)
97*d90bee97SLionel Sambuc
98*d90bee97SLionel SambucNCLIST nclist			# a case
99*d90bee97SLionel Sambuc	type	  int
100*d90bee97SLionel Sambuc	next	  nodeptr		# the next case in list
101*d90bee97SLionel Sambuc	pattern	  nodeptr		# list of patterns for this case
102*d90bee97SLionel Sambuc	body	  nodeptr		# code to execute for this case
103*d90bee97SLionel Sambuc
104*d90bee97SLionel Sambuc
105*d90bee97SLionel SambucNDEFUN narg			# define a function.  The "next" field contains
106*d90bee97SLionel Sambuc				# the body of the function.
107*d90bee97SLionel Sambuc
108*d90bee97SLionel SambucNARG narg			# represents a word
109*d90bee97SLionel Sambuc	type	  int
110*d90bee97SLionel Sambuc	next	  nodeptr		# next word in list
111*d90bee97SLionel Sambuc	text	  string		# the text of the word
112*d90bee97SLionel Sambuc	backquote nodelist		# list of commands in back quotes
113*d90bee97SLionel Sambuc
114*d90bee97SLionel SambucNTO nfile			# fd> fname
115*d90bee97SLionel SambucNCLOBBER nfile			# fd>| fname
116*d90bee97SLionel SambucNFROM nfile			# fd< fname
117*d90bee97SLionel SambucNFROMTO nfile			# fd<> fname
118*d90bee97SLionel SambucNAPPEND nfile			# fd>> fname
119*d90bee97SLionel Sambuc	type	  int
120*d90bee97SLionel Sambuc	next	  nodeptr		# next redirection in list
121*d90bee97SLionel Sambuc	fd	  int			# file descriptor being redirected
122*d90bee97SLionel Sambuc	fname	  nodeptr		# file name, in a NARG node
123*d90bee97SLionel Sambuc	expfname  temp	char *expfname	# actual file name
124*d90bee97SLionel Sambuc
125*d90bee97SLionel SambucNTOFD ndup			# fd<&dupfd
126*d90bee97SLionel SambucNFROMFD ndup			# fd>&dupfd
127*d90bee97SLionel Sambuc	type	  int
128*d90bee97SLionel Sambuc	next	  nodeptr		# next redirection in list
129*d90bee97SLionel Sambuc	fd	  int			# file descriptor being redirected
130*d90bee97SLionel Sambuc	dupfd	  int			# file descriptor to duplicate
131*d90bee97SLionel Sambuc	vname	  nodeptr		# file name if fd>&$var
132*d90bee97SLionel Sambuc
133*d90bee97SLionel Sambuc
134*d90bee97SLionel SambucNHERE nhere			# fd<<\!
135*d90bee97SLionel SambucNXHERE nhere			# fd<<!
136*d90bee97SLionel Sambuc	type	  int
137*d90bee97SLionel Sambuc	next	  nodeptr		# next redirection in list
138*d90bee97SLionel Sambuc	fd	  int			# file descriptor being redirected
139*d90bee97SLionel Sambuc	doc	  nodeptr		# input to command (NARG node)
140*d90bee97SLionel Sambuc
141*d90bee97SLionel SambucNNOT nnot			# ! command  (actually pipeline)
142*d90bee97SLionel Sambuc	type	  int
143*d90bee97SLionel Sambuc	com	  nodeptr
144