1/* 2 * C preprocessor library 3 */ 4 5:PACKAGE: ast 6 7LICENSE = since=1986,author=gsf 8 9ID = pp 10 11DEBUG == 12 13IDNAME = "$(ID)" 14 15$(ID) 2.0 :LIBRARY: BUGS NOTES RELEASE HISTORY pp.3 \ 16 pp.h ppfsm.h ppkey.h pplib.h pp.tab \ 17 ppargs.c ppbuiltin.c ppcall.c ppcomment.c \ 18 ppcontext.c ppcontrol.c ppcpp.c ppdata.c \ 19 pperror.c ppexpr.c ppfsm.c ppincref.c ppinput.c ppkey.c \ 20 pplex.c ppline.c ppmacref.c ppmisc.c ppop.c pppragma.c \ 21 ppprintf.c ppproto.c ppsearch.c pptrace.c 22 23"hp.pa*" :NOOPTIMIZE: ppfsm.c 24"osf.alpha*" :NOOPTIMIZE: ppcall.c 25"sol*.i386*" :NOOPTIMIZE: ppcpp.c pplex.c 26 27ppdef.h : gentab pp.tab 28 $(*:N=*gentab:P=A) -d $(*:N=*.tab) > $(<) 29 30pptab.h : gentab pp.tab 31 $(*:N=*gentab:P=A) -t $(*:N=*.tab) > $(<) 32 33:INSTALLDIR: gentab ppsym 34 35gentab :: gentab.sh 36 37ppsym :: ppsym.c +last 38 39/* MAM workaround */ 40if "$(-mam)" 41.ALL : .INSERT ppsym 42end 43 44$(INCLUDEDIR) :INSTALLPROTO: pp.h ppkey.h 45 46$(INCLUDEDIR) :INSTALLDIR: pp.yacc ppkey.yacc 47 48C $(ID) :PROBE: pp.probe pp.def pp.key ppsym probe.ini 49 50probe.ini : (CC.HOSTTYPE) probe.win32 51 t=$(CC.HOSTTYPE) 52 ifs=$IFS 53 IFS=. 54 set x $t 55 IFS=$ifs 56 t=$2 57 set x $(*) 58 while : 59 do shift 60 case $# in 61 0) break ;; 62 esac 63 case $1 in 64 *probe.$t) 65 break 66 esac 67 done 68 case $1 in 69 ?*) cmp -s $1 $(<) || cp $1 $(<) ;; 70 *) : > $(<) 71 esac 72 73%.yacc : %.h pp.h 74 $(RM) -f $(<) 75 { 76 $(*:N!=$(>):?$(SED) -n -e '/^#define T_TOKEN/p' -e '/^#define N_/p' $(*:N!=$(>))$("\n")??)cat $(>) 77 } > 1.$(tmp).c 78 $(STDED|ED) $(STDEDFLAGS|EDFLAGS) 1.$(tmp).c <<'!' 79 g/^#define N_/m0 80 v/^#define [NT]_/d 81 1,$s/^#define \(T_[A-Z0-9_]*\).*/&\ 82 printf(" \1 %d", \1);/ 83 g/^printf.*T_HEADER/d 84 g/^printf.*T_KEYWORD/d 85 g/^printf.*T_TOKCAT/d 86 g/^printf.*T_TOKEN/d 87 0a 88 $("#")include <stdio.h> 89 int 90 main(argc, argv) 91 int argc; 92 char** argv; 93 { 94 printf("%%token /*generated from $(>)*/"); 95 . 96 $a 97 printf("\n"); 98 return 0; 99 } 100 . 101 w 102 q 103 ! 104 $(CC.NATIVE|CC) -o $(tmp).exe 1.$(tmp).c 105 ./$(tmp).exe > $(<) 106 $(RM) -f 1.$(tmp).c $(tmp).exe 107 108ppdebug.h : ppfsm.h ppdef.h pplib.h 109 : > 1.$(tmp).c 110 $(STDED|ED) $(STDEDFLAGS|EDFLAGS) 1.$(tmp).c <<'!' 111 r $(*:N=*fsm.h) 112 1,/^#define PROTO/-d 113 /^#define LAST/,$d 114 v/^#define/d 115 g/PROTOMAIN/d 116 1,$s/^#define // 117 1,$s/[^A-Za-z0-9_].*// 118 1,$s/.*/ "&", &,/ 119 1i 120 $("/")* 121 * preprocessor library debug maps 122 *$("/") 123 struct map 124 { 125 char* nam; 126 long val; 127 }; 128 static struct map pplexmap[] = 129 { 130 . 131 $a 132 }; 133 . 134 ka 135 r $(*:N=*def.h) 136 $("'")a+1,/^#define ADD/-d 137 /^$/,$d 138 $("'")a+1,$s/^#define // 139 $("'")a+1,$s/[ ].*// 140 $("'")a+1,$s/.*/ "&", &,/ 141 $("'")aa 142 static struct map ppstatemap[] = 143 { 144 . 145 $a 146 }; 147 . 148 ka 149 r $(*:N=*def.h) 150 $("'")a+1,/^#define ALLMULTIPLE/-d 151 /^$/,$d 152 $("'")a+1,$s/^#define // 153 $("'")a+1,$s/[ ].*// 154 $("'")a+1,$s/.*/ "&", &,/ 155 $("'")aa 156 static struct map ppmodemap[] = 157 { 158 . 159 $a 160 }; 161 . 162 ka 163 r $(*:N=*def.h) 164 $("'")a+1,/^#define ELSEIF/-d 165 /^$/,$d 166 $("'")a+1,$s/^#define // 167 $("'")a+1,$s/[ ].*// 168 $("'")a+1,$s/.*/ "&", &,/ 169 $("'")aa 170 static struct map ppoptionmap[] = 171 { 172 . 173 $a 174 }; 175 . 176 ka 177 r $(*:N=*lib.h) 178 $("'")a+1,/^#define IN_BUFFER/-d 179 /^$/,$d 180 $("'")a+1,$s/^#define IN_// 181 $("'")a+1,$s/[ ].*// 182 $("'")a+1,$s/.*/ "&", IN_&,/ 183 $("'")aa 184 static struct map ppinmap[] = 185 { 186 . 187 $a 188 }; 189 . 190 w 191 q 192 ! 193 if $(CMP) -s 1.$(tmp).c $(<) 194 then $(RM) -f 1.$(tmp).c 195 else $(MV) 1.$(tmp).c $(<) 196 fi 197