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