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