1# 2# Copyright (c) 1991 The Regents of the University of California. 3# All rights reserved. 4# 5# This code is derived from software contributed to Berkeley by 6# Kenneth Almquist. 7# 8# %sccs.include.redist.sh% 9# 10# @(#)nodetypes 5.2 (Berkeley) 04/16/92 11 12# This file describes the nodes used in parse trees. Unindented lines 13# contain a node type followed by a structure tag. Subsequent indented 14# lines specify the fields of the structure. Several node types can share 15# the same structure, in which case the fields of the structure should be 16# specified only once. 17# 18# A field of a structure is described by the name of the field followed 19# by a type. The currently implemented types are: 20# nodeptr - a pointer to a node 21# nodelist - a pointer to a list of nodes 22# string - a pointer to a nul terminated string 23# int - an integer 24# other - any type that can be copied by assignment 25# temp - a field that doesn't have to be copied when the node is copied 26# The last two types should be followed by the text of a C declaration for 27# the field. 28 29NSEMI nbinary # two commands separated by a semicolon 30 type int 31 ch1 nodeptr # the first child 32 ch2 nodeptr # the second child 33 34NCMD ncmd # a simple command 35 type int 36 backgnd int # set to run command in background 37 args nodeptr # the arguments 38 redirect nodeptr # list of file redirections 39 40NPIPE npipe # a pipeline 41 type int 42 backgnd int # set to run pipeline in background 43 cmdlist nodelist # the commands in the pipeline 44 45NREDIR nredir # redirection (of a compex command) 46 type int 47 n nodeptr # the command 48 redirect nodeptr # list of file redirections 49 50NBACKGND nredir # run command in background 51NSUBSHELL nredir # run command in a subshell 52 53NAND nbinary # the && operator 54NOR nbinary # the || operator 55 56NIF nif # the if statement. Elif clauses are handled 57 type int # using multiple if nodes. 58 test nodeptr # if test 59 ifpart nodeptr # then ifpart 60 elsepart nodeptr # else elsepart 61 62NWHILE nbinary # the while statement. First child is the test 63NUNTIL nbinary # the until statement 64 65NFOR nfor # the for statement 66 type int 67 args nodeptr # for var in args 68 body nodeptr # do body; done 69 var string # the for variable 70 71NCASE ncase # a case statement 72 type int 73 expr nodeptr # the word to switch on 74 cases nodeptr # the list of cases (NCLIST nodes) 75 76NCLIST nclist # a case 77 type int 78 next nodeptr # the next case in list 79 pattern nodeptr # list of patterns for this case 80 body nodeptr # code to execute for this case 81 82 83NDEFUN narg # define a function. The "next" field contains 84 # the body of the function. 85 86NARG narg # represents a word 87 type int 88 next nodeptr # next word in list 89 text string # the text of the word 90 backquote nodelist # list of commands in back quotes 91 92NTO nfile # fd> fname 93NFROM nfile # fd< fname 94NAPPEND nfile # fd>> fname 95 type int 96 next nodeptr # next redirection in list 97 fd int # file descriptor being redirected 98 fname nodeptr # file name, in a NARG node 99 expfname temp char *expfname # actual file name 100 101NTOFD ndup # fd<&dupfd 102NFROMFD ndup # fd>&dupfd 103 type int 104 next nodeptr # next redirection in list 105 fd int # file descriptor being redirected 106 dupfd int # file descriptor to duplicate 107 108NHERE nhere # fd<<\! 109NXHERE nhere # fd<<! 110 type int 111 next nodeptr # next redirection in list 112 fd int # file descriptor being redirected 113 doc nodeptr # input to command (NARG node) 114 115NNOT nnot # ! command (actually pipeline) 116 type int 117 com nodeptr 118