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