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