xref: /freebsd/bin/sh/nodetypes (revision 9336e0699bda8a301cd2bfa37106b6ec5e32012e)
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# 4. Neither the name of the University nor the names of its contributors
17#    may be used to endorse or promote products derived from this software
18#    without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30# SUCH DAMAGE.
31#
32#	@(#)nodetypes	8.2 (Berkeley) 5/4/95
33# $FreeBSD$
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
52NSEMI nbinary			# two commands separated by a semicolon
53	type	  int
54	ch1	  nodeptr		# the first child
55	ch2	  nodeptr		# the second child
56
57NCMD ncmd			# a simple command
58	type	  int
59	backgnd	  int			# set to run command in background
60	args	  nodeptr		# the arguments
61	redirect  nodeptr		# list of file redirections
62
63NPIPE npipe			# a pipeline
64	type	  int
65	backgnd	  int			# set to run pipeline in background
66	cmdlist	  nodelist		# the commands in the pipeline
67
68NREDIR nredir			# redirection (of a compex command)
69	type	  int
70	n	  nodeptr		# the command
71	redirect  nodeptr		# list of file redirections
72
73NBACKGND nredir			# run command in background
74NSUBSHELL nredir		# run command in a subshell
75
76NAND nbinary			# the && operator
77NOR nbinary			# the || operator
78
79NIF nif				# the if statement.  Elif clauses are handled
80	type	  int		    # using multiple if nodes.
81	test	  nodeptr		# if test
82	ifpart	  nodeptr		# then ifpart
83	elsepart  nodeptr		# else elsepart
84
85NWHILE nbinary			# the while statement.  First child is the test
86NUNTIL nbinary			# the until statement
87
88NFOR nfor			# the for statement
89	type	  int
90	args	  nodeptr		# for var in args
91	body	  nodeptr		# do body; done
92	var	  string		# the for variable
93
94NCASE ncase			# a case statement
95	type	  int
96	expr	  nodeptr		# the word to switch on
97	cases	  nodeptr		# the list of cases (NCLIST nodes)
98
99NCLIST nclist			# a case
100	type	  int
101	next	  nodeptr		# the next case in list
102	pattern	  nodeptr		# list of patterns for this case
103	body	  nodeptr		# code to execute for this case
104
105
106NDEFUN narg			# define a function.  The "next" field contains
107				# the body of the function.
108
109NARG narg			# represents a word
110	type	  int
111	next	  nodeptr		# next word in list
112	text	  string		# the text of the word
113	backquote nodelist		# list of commands in back quotes
114
115NTO nfile			# fd> fname
116NFROM nfile			# fd< fname
117NFROMTO nfile			# fd<> fname
118NAPPEND nfile			# fd>> fname
119NCLOBBER nfile			# fd>| fname
120	type	  int
121	next	  nodeptr		# next redirection in list
122	fd	  int			# file descriptor being redirected
123	fname	  nodeptr		# file name, in a NARG node
124	expfname  temp	char *expfname	# actual file name
125
126NTOFD ndup			# fd<&dupfd
127NFROMFD ndup			# fd>&dupfd
128	type	  int
129	next	  nodeptr		# next redirection in list
130	fd	  int			# file descriptor being redirected
131	dupfd	  int			# file descriptor to duplicate
132	vname	  nodeptr		# file name if fd>&$var
133
134
135NHERE nhere			# fd<<\!
136NXHERE nhere			# fd<<!
137	type	  int
138	next	  nodeptr		# next redirection in list
139	fd	  int			# file descriptor being redirected
140	doc	  nodeptr		# input to command (NARG node)
141
142NNOT nnot			# ! command  (actually pipeline)
143	type	int
144	com	nodeptr
145