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