nodetypes revision 96922
155714Skris# 255714Skris# Copyright (c) 1991, 1993 355714Skris# The Regents of the University of California. All rights reserved. 455714Skris# 555714Skris# This code is derived from software contributed to Berkeley by 655714Skris# Kenneth Almquist. 755714Skris# 8280297Sjkim# Redistribution and use in source and binary forms, with or without 955714Skris# modification, are permitted provided that the following conditions 1055714Skris# are met: 1155714Skris# 1. Redistributions of source code must retain the above copyright 1255714Skris# notice, this list of conditions and the following disclaimer. 1355714Skris# 2. Redistributions in binary form must reproduce the above copyright 1455714Skris# notice, this list of conditions and the following disclaimer in the 15280297Sjkim# documentation and/or other materials provided with the distribution. 1655714Skris# 3. All advertising materials mentioning features or use of this software 1755714Skris# must display the following acknowledgement: 1855714Skris# This product includes software developed by the University of 1955714Skris# California, Berkeley and its contributors. 2055714Skris# 4. Neither the name of the University nor the names of its contributors 2155714Skris# may be used to endorse or promote products derived from this software 22280297Sjkim# without specific prior written permission. 2355714Skris# 2455714Skris# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2555714Skris# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2655714Skris# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2755714Skris# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2855714Skris# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2955714Skris# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3055714Skris# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3155714Skris# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3255714Skris# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3355714Skris# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3455714Skris# SUCH DAMAGE. 3555714Skris# 3655714Skris# @(#)nodetypes 8.2 (Berkeley) 5/4/95 37280297Sjkim# $FreeBSD: head/bin/sh/nodetypes 96922 2002-05-19 06:03:05Z tjr $ 3855714Skris 3955714Skris# This file describes the nodes used in parse trees. Unindented lines 40280297Sjkim# contain a node type followed by a structure tag. Subsequent indented 4155714Skris# lines specify the fields of the structure. Several node types can share 4255714Skris# the same structure, in which case the fields of the structure should be 4355714Skris# specified only once. 4455714Skris# 4555714Skris# A field of a structure is described by the name of the field followed 4655714Skris# by a type. The currently implemented types are: 4755714Skris# nodeptr - a pointer to a node 4855714Skris# nodelist - a pointer to a list of nodes 4955714Skris# string - a pointer to a nul terminated string 5055714Skris# int - an integer 5155714Skris# other - any type that can be copied by assignment 52280297Sjkim# temp - a field that doesn't have to be copied when the node is copied 5355714Skris# The last two types should be followed by the text of a C declaration for 5455714Skris# the field. 5555714Skris 5655714SkrisNSEMI nbinary # two commands separated by a semicolon 5755714Skris type int 5855714Skris ch1 nodeptr # the first child 5955714Skris ch2 nodeptr # the second child 6055714Skris 6155714SkrisNCMD ncmd # a simple command 62160814Ssimon type int 63280297Sjkim backgnd int # set to run command in background 64280297Sjkim args nodeptr # the arguments 65280297Sjkim redirect nodeptr # list of file redirections 6655714Skris 67280297SjkimNPIPE npipe # a pipeline 68280297Sjkim type int 69280297Sjkim backgnd int # set to run pipeline in background 70194206Ssimon cmdlist nodelist # the commands in the pipeline 71160814Ssimon 72160814SsimonNREDIR nredir # redirection (of a compex command) 7355714Skris type int 74280297Sjkim n nodeptr # the command 75280297Sjkim redirect nodeptr # list of file redirections 76280297Sjkim 77280297SjkimNBACKGND nredir # run command in background 78280297SjkimNSUBSHELL nredir # run command in a subshell 79280297Sjkim 80280297SjkimNAND nbinary # the && operator 81280297SjkimNOR nbinary # the || operator 82280297Sjkim 83280297SjkimNIF nif # the if statement. Elif clauses are handled 84280297Sjkim type int # using multiple if nodes. 85280297Sjkim test nodeptr # if test 86280297Sjkim ifpart nodeptr # then ifpart 87280297Sjkim elsepart nodeptr # else elsepart 88280297Sjkim 89280297SjkimNWHILE nbinary # the while statement. First child is the test 90160814SsimonNUNTIL nbinary # the until statement 91160814Ssimon 92280297SjkimNFOR nfor # the for statement 93280297Sjkim type int 94280297Sjkim args nodeptr # for var in args 95280297Sjkim body nodeptr # do body; done 9655714Skris var string # the for variable 97280297Sjkim 98280297SjkimNCASE ncase # a case statement 9955714Skris type int 100280297Sjkim expr nodeptr # the word to switch on 101280297Sjkim cases nodeptr # the list of cases (NCLIST nodes) 102280297Sjkim 103280297SjkimNCLIST nclist # a case 104280297Sjkim type int 10555714Skris next nodeptr # the next case in list 106280297Sjkim pattern nodeptr # list of patterns for this case 107280297Sjkim body nodeptr # code to execute for this case 108280297Sjkim 109280297Sjkim 11055714SkrisNDEFUN narg # define a function. The "next" field contains 111280297Sjkim # the body of the function. 112280297Sjkim 113280297SjkimNARG narg # represents a word 114280297Sjkim type int 115280297Sjkim next nodeptr # next word in list 11655714Skris text string # the text of the word 117280297Sjkim backquote nodelist # list of commands in back quotes 118280297Sjkim 119280297SjkimNTO nfile # fd> fname 12055714SkrisNFROM nfile # fd< fname 121280297SjkimNFROMTO nfile # fd<> fname 122280297SjkimNAPPEND nfile # fd>> fname 123280297SjkimNCLOBBER nfile # fd>| fname 124280297Sjkim type int 125280297Sjkim next nodeptr # next redirection in list 126280297Sjkim fd int # file descriptor being redirected 127160814Ssimon fname nodeptr # file name, in a NARG node 128280297Sjkim expfname temp char *expfname # actual file name 129280297Sjkim 130280297SjkimNTOFD ndup # fd<&dupfd 13155714SkrisNFROMFD ndup # fd>&dupfd 132280297Sjkim type int 133280297Sjkim next nodeptr # next redirection in list 134280297Sjkim fd int # file descriptor being redirected 135280297Sjkim dupfd int # file descriptor to duplicate 136280297Sjkim vname nodeptr # file name if fd>&$var 137280297Sjkim 138280297Sjkim 139280297SjkimNHERE nhere # fd<<\! 140280297SjkimNXHERE nhere # fd<<! 141280297Sjkim type int 142280297Sjkim next nodeptr # next redirection in list 143280297Sjkim fd int # file descriptor being redirected 144280297Sjkim doc nodeptr # input to command (NARG node) 14555714Skris 146NNOT nnot # ! command (actually pipeline) 147 type int 148 com nodeptr 149