aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

nodetypes (5173B)


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