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