Trailing-Edge
-
PDP-10 Archives
-
decuslib10-08
-
43,50512/macs.req
There are no other files named macs.req in the archive.
!Require file to define some useful macros for lexical processing
!THIS_IS determines the symbols generated by the following macros (the 'xxx')
!VERSION,VMINOR, and EDIT macros generate an LCG version #
! known by the symbol V.xxx
! EDIT must be called after VERSION and/or VMINOR
!DATE generates DDMMYY in decimal (D.xxx)
!STRINGCOMMAS[a,b,c,...,z] returns a, ',', b, ',', c,',',...,z
! so you can get a string with commas separating your arguments
!DFF[F,A,B,C...] defines field F=[A,B,C...] and generates a %PRINT with values
! 0 is the first character position
!FIRSTWORD sets THISWORD (which must be declared COMPILETIME) to 0
! and returns 0
!NEXTWORD incremeents THISWORD and returns its new value
!MWORDS(N) increments THISWORD by N words and returns new value
!PHASE(N) sets THISWORD to N, returns null lexeme
!DLIT(M,N) defines M=N as a literal & generates a %PRINT of it
!INSTR[STR,SSTR] returns the index of the start of SSTR in STR or -1 if failed
!CDR[...] returns its argument list minus its first argument
!CDRN[N,...] returns its argument list minus its first N+1 arguments
!CDRS[STR] returns its string argument with the first character removed
!CDRNS[N,STR] returns its second argument (a string) minus its first N chars
!EXTD[N,...] make args external if not defined already
!INTERN[...] Declares its (compiletime constant) arguments GLOBAL
!$INCR(INDEX,START,END,BODY) Compile-time version of INCR
!CLEARV[N,...] Zero a variable.
LITERAL JAN=1,FEB=2,MAR=3,APR=4,MAY=5,JUN=6,JUL=7,AUG=8,SEP=9,OCT=10,
NOV=11,DEC=12;
COMPILETIME VERS_=0;
MACRO
THIS_IS(NAM)=
MACRO MODULE_NAME=NAM %QUOTE %; %,
MODULE_NAME_IS(NAM)=
%ASSIGN(VERS_,0)
MACRO MODULE_NAME=NAM %QUOTE %; %,
VERSION(VER)=
%ASSIGN(VERS_,(%O%STRING(VER)^24)); %,
VMLETTERS(A,B)=
(((%C %STRING(A)-%C'@')
%IF NOT %NULL(B) %THEN *26)+(%C %STRING(B)-%C'@') %ELSE )) %FI%,
VMINOR(VM)=
%ASSIGN(VERS_,VERS_+VMLETTERS(%EXPLODE(%STRING(VM)))^18) %,
EDIT(ED)=GLOBAL LITERAL %NAME('V.',MODULE_NAME)=
VERS_+%O%STRING(ED); %,
DATE(DD,MM,YY)=GLOBAL LITERAL %NAME('D.',MODULE_NAME)=
(DD*10000)+(MM*100)+YY; %;
MACRO STRINGCOMMAS[I]=I,%IF (%LENGTH-%COUNT) GTR 1 %THEN','%FI%;
MACRO DFF(F)[]=
F=[%REMAINING] %PRINT(F,'=[',STRINGCOMMAS(%FIELDEXPAND(F)),']') %;
COMPILETIME THISWORD=0;
MACRO SUBSTR(STR,I,N)=%EXACTSTRING(N,0,CDRNS(I,STR))%,
INSTR(STR,SSTR)[]=
%IF %IDENTICAL(%EXACTSTRING(%CHARCOUNT(SSTR),0,STR),SSTR)
%THEN %COUNT %EXITMACRO
%ELSE %IF %CHARCOUNT(STR) EQL 0 %THEN -1 %EXITMACRO
%ELSE INSTR(CDRS(STR),SSTR) %FI %FI %,
CDRNS(N,STR)=%STRING(CDRN(N,%EXPLODE(STR)))%,
CDRN(N,FIRST)[]=%IF N LEQ %COUNT
%THEN FIRST,%REMAINING %EXITMACRO %FI
CDRN(N,%REMAINING)%,
CDRS(STR)=%STRING(CDR(%EXPLODE(STR)))%,
CDR(FIRST)[]=%REMAINING%;
MACRO FIRSTWORD=%ASSIGN(THISWORD,0)0%,
NEXTWORD=%ASSIGN(THISWORD,THISWORD+1)THISWORD%;
MACRO WRD=0,36,0%, !Full word field
LH=18,18,0%, !Left halfword
RH=0,18,0%; !Right halfword
MACRO MWORDS(N)=%ASSIGN(THISWORD,THISWORD+N)
(THISWORD+1-N)%,
PHASE(N)=%IF NOT %DECLARED(THISWORD)%THEN (COMPILETIME THISWORD=0) %FI
%ASSIGN(THISWORD,N)%,
DLIT(M,N)=LITERAL M=(N); %PRINT(M,'=',%NUMBER(M))%;
MACRO EXTD[N]=%IF NOT %DECLARED(N) %THEN EXTERNAL N %FI%;
MACRO INTERN[X]= BEGIN
COMPILETIME Y=X; !Save its value
UNDECLARE X; !To avoid multiple def
GLOBAL BIND X=Y;
Y
END%,
$INCR(IND,STA,FIN)[]= BEGIN
%IF NOT %DECLARED (INCR$$STEP)
%THEN COMPILETIME INCR$$STEP=1;
%FI
COMPILETIME IND=STA; !Set index counter
%IF IND LEQ FIN
%THEN %REMAINING;
$INCR(IND,(STA+INCR$$STEP),FIN,%REMAINING)
%FI
END%,
CLEARV[VAR]= BEGIN
COMPILETIME SIZ=%ALLOCATION(VAR)-1;
BEGIN
MAP VAR: VECTOR;
%IF (SIZ-7) LSS 0
%THEN $INCR(I,0,SIZ,(VAR[I]=0))
%ELSE
INCR I FROM 0 TO SIZ
DO VAR[.I]=0
%FI
END
END%;