1$ ! sys/vms/spec_lev.com -- preprocess nethack's special level compiler code 2$ ! 3$ ! This operation needs to be performed prior to executing vmsbuild.com. 4$ ! Process the scanning and parsing code for NetHack's special level 5$ ! and dungeon compilers. *.l and *.y are converted into *'.c and *.h. 6$ ! 7$ 8$ ! setup yacc/bison and lex/flex; 9$ ! (Uncomment the alternatives appropriate for your site; 10$ ! if yacc and lex are not defined, the pre-processed files 11$ ! distributed in sys/share will be copied and used.) 12$ ! yacc := bison /Define !native bison (w/ DCL CLD) 13$ ! yacc := $bison$dir:bison -y -d !'foreign' bison (w/o CLD) 14$ ! yacc := posix /Run/Input=nl: posix$bin:yacc. """-d 15$ ! yacc := $shell$exe:yacc -d !yacc from DEC/Shell 16$ ! lex := $flex$dir:flex !flex 17$ ! lex := posix /Run/Input=nl: posix$bin:lex. """ 18$ ! lex := $shell$exe:lex 19$ ! (Nothing below this line should need to be changed.) 20$ ! additional setup 21$ rename := rename/New_Vers 22$ mung := call mung ! not to be confused with teco :-) 23$ delete := delete/noConfirm 24$ search := search/Exact 25$ copy := copy/noConcat 26$ ! start from a known location -- [.sys.vms], then move to [-.-.util] 27$ cur_dir = f$environment("DEFAULT") 28$ set default 'f$parse(f$environment("PROCEDURE"),,,"DIRECTORY")' 29$ set default [-.-.util] !move to utility directory 30$ 31$mung: subroutine 32$ ! kludge to strip bogus #module directives from POSIX-processed files 33$ ! in lieu of $ rename 'p1' 'p2' 34$ search/Match=NOR 'p1' "#module" /Output='p2' 35$ delete 'p1';* 36$ endsubroutine !mung 37$ 38$ ! first cleanup any old intermediate files (to safely handle blind renaming) 39$ if f$search("*tab.%").nes."" then delete *tab.%;* !yacc & bison 40$ if f$search("*yy.c") .nes."" then delete *yy.c;* !lex & flex 41$ 42$ ! process lev_comp.y into lev_yacc.c and ../include/lev_comp.h 43$ if f$type(yacc).eqs."STRING" 44$ then 45$ yacc lev_comp.y 46$ if f$search("y_tab.%").nes."" then rename y_tab.% lev_comp_tab.* 47$ if f$search("ytab.%") .nes."" then rename ytab.% lev_comp_tab.* 48$ else ! use preprocessed files 49$ copy [-.sys.share]lev_yacc.c,lev_comp.h []lev_comp_tab.* 50$ endif 51$ mung lev_comp_tab.c lev_yacc.c 52$ rename lev_comp_tab.h [-.include]lev_comp.h 53$ 54$ ! process lev_comp.l into lev_lex.c 55$ if f$type(lex).eqs."STRING" 56$ then 57$ lex lev_comp.l 58$ if f$search("lexyy.c").nes."" then rename lexyy.c lex_yy.* 59$ else ! use preprocessed file 60$ copy [-.sys.share]lev_lex.c []lex_yy.* 61$ endif 62$ mung lex_yy.c lev_lex.c 63$ 64$ ! process dgn_comp.y into dgn_yacc.c and ../include/dgn_comp.h 65$ if f$type(yacc).eqs."STRING" 66$ then 67$ yacc dgn_comp.y 68$ if f$search("y_tab.%").nes."" then rename y_tab.% dgn_comp_tab.* 69$ if f$search("ytab.%") .nes."" then rename ytab.% dgn_comp_tab.* 70$ else 71$ copy [-.sys.share]dgn_yacc.c,dgn_comp.h []dgn_comp_tab.* 72$ endif 73$ mung dgn_comp_tab.c dgn_yacc.c 74$ rename dgn_comp_tab.h [-.include]dgn_comp.h 75$ 76$ ! process dgn_comp.l into dgn_lex.c 77$ if f$type(lex).eqs."STRING" 78$ then 79$ lex dgn_comp.l 80$ if f$search("lexyy.c").nes."" then rename lexyy.c lex_yy.* 81$ else 82$ copy [-.sys.share]dgn_lex.c []lex_yy.* 83$ endif 84$ mung lex_yy.c dgn_lex.c 85$ 86$ ! done 87$ set default 'cur_dir' 88$ exit 89