Home
THE BIGMAC USER'S MANUAL
Contents
1. 27 2 47 External Functions STREX provides three simple external functions These are out lined in the chart below No of arguments Type of Definition arguments Type of result LENSTR STRING INTEGER The length of the argument STRING LOGICAL True only if the two string arguments are identical SEARCH STRING INTEGER 0 if the first argument is not a substring of the second Otherwise SEARCH gives the index of the leftmost character in the leftmost occur rence of the first argument in the second 3 MACRO FEATURES BIGMAC s macro capabilities are discussed at some length in the last three sections of the first part of this manual particular the semantics of text transformations and name generation are specified to the extent that this section only presents the STREX syntax for these primitives The expression analysis package will be presented more thoroughly in subsection 3 3 below 200 Transformation Primitives The text transformation primitives of BIGMAC are realized syntactically as STREX statements syntax of each statement is listed below along with a brief semantic description 1 COMMENT expression e STRING If the length of the expression is over 77 characters an error message is issued and the string is truncated on the right A fragment of the comment type is appended to output The C
2. 5 5 0 5 is in Polish prefix form PTATSTSTZ Te Pen Tees T MIN is an operator Arguments are on 3 arguments not decomposed where each block is a token The expression s final token string encoding is Lg 1503732014042 19544 51 1539 13 78 10 1 15 775 OP 551065 071618 0 18 22 0 22 24 The parsing package consists of four routines The header section of each routine is given below along with a discussion of its effect Note the close association required between a token string and the original string from which it was created by the PARSE routine 1 STRING FUNCTION PARSE EXPSTR STRING EXPSTR EXPSTR is an input parameter whose value is a string denoting a valid ANSI FORTRAN expression The result of PARSE is the token string for the expression in EXPSTR The index pairs of every token refer to locations in EXPSTR 294 2 INTEGER FUNCTION GETTOK TOKSTR I LINDEX RINDEX INTEGER I LINDEX RINDEX STRING TOKSTR TOKSTR is an input parameter which is a token string of say N tokens is an input parameter and LINDEX and RINDEX are output parameters If lt O or I gt N then GETTOK returns 1 Otherwise GETTOK returns the token code of the Ith token from the left and also has the side effect of setting LINDEX and RINDEX to the left and right indices of the Ith token 3 STRING FUNCTION ADDTOK TOKCOD ACTSTR EXPSTR STRING ACTSTR EXPSTR INTEGER TOKCOD TOKCOD is an inp
3. An arithmetic or logical expression between equal signs yields a string which is a constant denotation for the value of that expression In the case of COMPLEX DOUBLE PRECISION and REAL expressions the denotation is only a close approximation and is machine dependent Example 5 4 3 evaluates to 133333333333333E 1 on the CDC 6600 but IBM 370 the result is 1333333E 1 1 GT 0 evaluates to TRUE on any machine 5 Substring Selection Suppose the primary evaluates to the string S and further that expression evaluates to L and expression evaluates to R If S is undefined or L lt 0 or R gt length S 1 or L lt R then an error is issued Otherwise the resulting term is the substring of S lying exclusively between the Lth and Rth characters If more than one pair of selection indices is involved then they group from left to Currently only INTEGER expressions can be converted 26 right For example if V has the value then V 1 4 1 3 is equivalent to V 1 4 1 3 and has the value C 6 Concatenation The concatenation of a sequence of strings is expressed by separating each term by periods If any term is undefined an error is noted subexpressions involving concatenation occur at more than fifty different nested levels then a stack error will occur This should never happen in practice e g has just 3 levels has just 1 level
4. declaration String mode functions referenced in a program unit may be declared in that program unit with the syntax 15 type statement lt FSTRING lt name gt ty name String statement functions are not allowed Function statements are introduced in section 8 3 1 of the ANSI Standard STREX allows functions to return string values via the syntax 2 fct statement lt STRING FUNCTION fct name formal param formal param The semantic implications of these forms should be obvious from analogy with their Standard couterparts cited above Example 2 STRING FUNCTION SFUN AVAR ALEN SVAR STRING AVAR 10 SVAR FSTRING SFUN2 INTEGER ALEN DO 10 I 1 ALEN 10 AVAR I SFUN2 I SFUN SVAR RETURN END wee 2 2 y String Assignments In STREX there are two types of string assignment statements The syntax and semantics of the first form is a direct extension of the assignment statements defined in the ANSI Standard Zettel 1 assignment statement lt variable reference STRING z expression e STRING gt If the variable reference is also a parameter of the program unit containing the assignment and further if this parameter s value was obtained by the pass by value mechanism then an error has occurred and is flagged Otherwise execution of this construction causes the referenced variable to bind to the string value resulting from the evaluation of the expres
5. gt Meet Luar e 1 lyar var var Thus if a number of different macro actions place text fragments just prior to the same A statement fragment then those fragments will occur in the order of activation of the corresponding routine refer ences But by the observation above this order is a reflection of the order of semantic evaluation of the A statement s parse tree Hence the requirement of the A Statement Condition is in essence extended to the expression level 3 MACRO ACTION SET STRUCTURE Not every macro name in a macro action set need be in the recog nition table Those names that are in the recognition table are termed primary All other macros in the action set are auxillary and presumably used to modularize a complicated macro action frequent user can build libraries of auxillary macro actions and use them to augment the action set of a particular macro module course macro module will have a set of action names which is a superset of the names in the recognition table The compiled macro actions utilize a number of system routines which implement A string data type sub language A text transformation package A variety of primitives for analyzing the structure of the input stream as a FORTRAN proaram The semantics of BIGMAC s string extension are quite conventional and are discussed at length in the second part of this manual The other features are the subject of the f
6. s oNI1 G dAL1 s ONIL 8 G HVAI NIVANI 883030 10dJM1S NOWWOD 9386 5 3 11009805 082 SYN O O O O O OOO oc 01 OD s 0 1 dA11 S 0 3dAL1 41S03 SI S 1z1 oz 0 OL 09 t 11 3dA1 H1SN31 41 YSOSLINI SI 11 JWASSY ONY 30883 NV 3nSSI 318VIJIIN3GI LON XOV1S 3Hl dO 3 AJIIN3QI L M1SO MISO ZL 3nNIINOO bh uni3q vollana 1S H81S03 LON 41 4 1S2 1zI OG 09 070374152 dI OF WOVLS NOII1V39JO 31 t OL OD 1 SWYN HOV 3002 3N3931NI 318VTIVAV 4 3 JHL LI NOISSV ONY SI JWYN MOWLS 3Hl 1 WO3HO Nunaq 3nM1 X43230 SYJYLS 001 OL GD 01721179152 JI xt 1 383030 41 Na ni3H8 JHL 388 JHL NI 0317102364 N338 3AVH SMOVI1S OF NVHL 80 80853 NOIIVUVIO3QO V dI 1S10 1S32 1 N31 X2VI1S 3dAL ONTYLS MiSO SdAL QONII 839341NI SHId SN31 SUHVN dALLI HVAI ONIYLS ONIL NIV NI 44323G80 1V321901 162 01364 1 0196814 0135831 012060 2 s oNIL1 S dA11 S QNIL1 8 S 5VAL L NIVANI 83883238 1094 15 NOWIAOO N31 woviS 3dAl1 uv103G0 3NIInONS8nS QMOVIN N3n13H 3nNILiNOO 01 S I dALL1 34v17030 8 S S 709 134 11 MIS NOWAOOS 3Hv103Q0 u M3N39 S 01 OS 1 3I S t I OG 3n8l NI VINI NUNLAY NIVANI 41 3NIL1nOSN NIVW 3Hl NI Q38n19NI 13A LON S3dAL 3SOHL JO S
7. 2 Substring Selection Level 3 primary STRING lt reference STRING Reference expression STRING Parenthesis constant STRING gt Constant lt expression e STANDARD gt Conversion We discuss each of the constructions the paragraphs below LE Reference As for arithmetic primaries 6 1 string primaries can be a variable an array element or a function reference whose mode is STRING Exectution of a reference yields the value to which the reference is currently bound If the reference is undefined then the recovery action is dependent on the semantic action requiring its value see appendix B 2 Parenthesis As for all ANSI expressions parentheses can be used in string expressions to enforce an arbitrary order of evaluation 25 3 Constant A string constant denotation has the following syntax constant e STRING lt character less dollar gt character less dollar Fortran Characters gt Since dollar sign is the delimiting character one has to use two dollar signs to denote one within the constant string Example 4 HELLO has the value HELLO 3 has the value 3 A string constant may not be used in a data initialization state ment This restriction is somewhat cumbersome but the effect is easily simulated by explicitly initializing the string variables in the SYSBEG macro see part 1 section3 4 Conversion
8. 3 I 1 ADDTOK 4 9 EXPR 10 CONTINUE 20 REPL RPARSE TOKSTR EXPR RETURN END A call of the form S REPL 3 LEN A LEN results in S having the value 3 9 A 9 236 3 4 Environment Primitives A number of system functions are provided for analyzing the local and global variables of the procedure currently being scanned when a macro expansion takes place There are functions for determining whe ther or not a given common block or variable name is present in the procedure One can also determine the type of a variable which is local to the scanned program unit functions are 1 LOGICAL FUNCTION CTHERE NAME STRING NAME CTHERE is true if and only if a common block named NAME is in the currently scanned procedure If name is undefined CTHERE is false 2 LOGICAL FUNCTION VTHERE NAME STRING NAME VTHERE is true if and only if a variable named NAME appears in the scanned procedure If name is undefined VTHERE is false 3 INTEGER FUNCTION VTYPE NAME ARRAY STRING NAME LOGICAL ARRAY VTYPE is an integer code for the type of the variable named NAME VTYPE 0 NAME is undefined 1 NAME does not appear as variable name in the procedure 2 NAME appears as an INTEGER variable 3 NAME appears as a REAL variable 4 NAME appears as a DOUBLE PRECISION variable 5 NAME appears as a COMPLEX variable 6 NAME appears as a LOGICAL variable 4275 The flag ARRAY will be true if and only if is use
9. MisQhN Q311398v1 IN3AH31V1S JHL Ol S3HONYVH8 HOIHM LNG 34 31VIBNdCOHcdV 3 JO AuvHuOdW3l 318 IX3N YOVLS JHL dO 401 SdOd HOTHM 20299 31V83N39 83 dI ONY 9 15 804 3000 839 3Hl 3Nih dliQ HOIHM M393iNI S M130NDn WOVIS SNIMHIS HLSO SdAL ANIL N3931NI SHLld SN31 SUVN dALL NHVAL ONIMIS ONIL NIV ANI HN3230 1V29I901 MLSO COLISGALS 01 591 OL SN31 0 OSUVN S ONIL S dAL1 S GNIL1 8 S HVAL L NIVANI 4253030 1 MI4ZONN HOVLS dOd NOILONAS ONTYLS OMOVIN _ NYALSY 1 S WOWLS 310023X3 13 8 0 0109 1 5 37 19 4I 31n23X3 614 S S 31n23X3 1 6 14 lt 5 NUNL3Y 0 O3 I AI MOVIS HOIHM I 581220 MO14H3AO0 NV 41 M134AO 037173977 IN3JIVIS 3Hi Ol S3HONVu8g HOIHM 1 MOViS JHL 30 401 SHL OINO IWSLT SHS d HOIHM 3209 0832 41 MOVi1S 8034 3902 83931NI JH 3NIWZ313Q HOTHM 839321NI OOOO 3O 220 NHni3H I HOIHM NYNLAY 0 HOIHM a31v349 LON 2 16 2 165 40863 OL 09 X83930 dI 7 3nNIL1NOO 02 01 09 I SWvN 2vi1S u1s03 41 1S2 1721 OQ bt 0 09 0 63 M1S2 JI 0 NYN13 OL COLSW dOdt OL W dOd OL W dOd 01 W dOd OL W dOdt OlL W dOd OL W dOd OL W dOdt Of WidOd W HSAd TIVO Cor ot di dGd w H
10. in column 1 and blanks in columns 2 and 3 are automatically generated before the fragment is printed by an output formatter These fragments are not a part of the final output 2 LABEL expression STRING gt If the expression is over 5 characters long an error is issued and the string truncated on the right If the string is the empty string then no action is taken Otherwise a fragment of the label type is appended to output Labels are right justified by the BIGMAC formatter 3 ERROR expression e STRING The string may be of arbitrary length BIGMAC formatter breaks the string into a number of lines if necessary and tacks a header in front of it These fragments are not a part of the final output 4 EXECUTE expression e STRING If the expression is over 1320 characters long an error is issued and the expression is truncated on the right frag ment of the statement type is append to output unless the string is the empty string in which case no action is taken The BIGMAC formatter automatically breaks the string into con tinuation lines if necessary iS 30 DECLARE lt expression STRING gt The effect is the same as EXECUTE above except that the fragment is inserted at the DIP of the program unit currently being scanned EXECUTE expression STRING expression STRING This statement is an abbreviation for the two statement sequence LABEL expre
11. 8N3931NI 21 31 2 38 3931 S8I N31 8 U3931NI VI N31 V 9 N31 93931NI oI ai vi o g v Na1 GQvAL1S 3NILnouans OE 01 Sans HSfd sens HSNd dOd dOd 8 066109 101 21 2 050109 31 190 21 3 21 21 1 11 11 11 1510I 020109 0 331 11 dI 010109 O0I OI 11 1 0 0105 N21 19 1 1 4I 11 11 01 81 81 8700I 020109 0731 81 41 L vI VI VI V 01 020109 07317 1 31 1I N31 183931NI OI N31 2483931NI SI N31 883931NI VI N31 V83931NI N318H3031NI o1 81 vi O g v N31 QOvYMIS3NIinOSN8fs Ce 06 Ot Q e St 0 0 S 61 101 T4 9 0 0 c 5 6 0 0 SIN3W31V1S 318vinO3X3 SLIN3MWWO2O SHUguu3 SNOTIVAILOV QgvMis 40 AYVAWAS SNOIIVAILOV ON 303 40 AUVAWNNS SNOISNYdX3 St 0 0 S 5717101 9 0 0 HSfld 6 0 9 gt dOd SIN3MN31V1S 318v10n23X3 5 580383 SNOIIVAIIOV OUOVIN AUVNNS 4 52 The final example is an extension of the second and demonstrates the power of BIGMAC in implementing data abstractions The data abstrac tion stack is supported with the macros 1 SUBROUTINE DECLAR lt type gt lt name gt length name is a variable name type is a key word for one of the five standard types length is an integer constant or parameter DECLAR declares lt name gt to be
12. AOV XOV MOV AOv1V3MH OcOov olrov ooov zov AOV XOV MOV AOV V3HMLIS NCINZOO C1 6 s01 39N31VAInO3 13 6H393INI 1 d rOI SON31vAIDnO3 1 d H3O931NI 1130 0 1 071 91901 nov iov Sov sov oov dOV OOV NOV1V21001 nov iov sov auov cO0v dOV OOV NOV 901M15S NOtiiO2 CLIN COLISONS TVAINOSA 1 NNOISIO2Ha318nC 10 10 90 JOYVNOISIO3Ud WOvy a0V wov nrov riOv Hov 50v Jov nOOMHiS l CCLON 101 329N3 30 0 20 80 0 60 80 3ov aOov o0v gov vov oov gov Z0v WOOMJS NOINAOO Ci u cor 329N31vA1003 1 og vu3aS31NI 7 90v gov vov EOV cOV LOV OOV OVH3O3INI 9oV sov vov coY cov Lov ooV OvV L1NIMIS NOL 4V1SIW3NIi1nouans sans QNI3DJJd ee ea NUNLIY pe LOV 30V O00v4 20v gOV VOV 60V 80V A40V 2 LOIDM 0LO105 L1719 LOT SI HS d L LOT 101 1 0 CLOT W LoVv dOd OLOL109 1 31 101 dI 1 0 0 10I Ws30V 010109 1 31 101 41 L LOI 101 101 W d0V dOd 010109 1 31 101 41 L 10I 10 f1OI N 2O0V 0101059 1 31 10I 41 L 1017210I 101 80V dOd 010109 1 31 101 41 1 101 101 LOI W VvOV 01O1059 1 31 101 dI L I01z10I 10IDJUi eov 01C109 1731 7101 dI L 1012101 10I N 80V dOd 010109 17317101 dI 0 0 10I W A40V dOd 0101059 1 31 1
13. DHdSW 35998016 56 64 C SHH M 16 W2 61 S ADNYdNDDO AVONIN 9670 236 26 dd 0 238 dd 6870 ONISS3O0uUd 99 v 20 90 btl 1 17 84 9vcv XIVd 009 1509 gor 009 0 NOY Ql 13 ld 99 v 00954 QN380n S06 90 vl dOrs eOo 90 vl 14 9S SO HL CISNIYW SS ISNIVS o O1 Pea ss so rl 0 01 08760101 OrZvsar x1vdsnad Pngodxa i139 cg 6C rt 37 31318402 AdOO E SO v n8O ISNIVN 38 JHAGOO ZE SO0 vl ISNIVNW OQNIA3H Z 0 U01 8 OE S0 vl 8 8 ISNIVWsW ISNIV3sI SANVN3H OVADSIS 11v2 0 8S0 t ISNIV3 ONIM3H OE SO v01 53714 0 43533 1 3 103706 SORE LAALAOISNIVS 3854 66 S0 tl ISNIV3 130 8Z2 S0 v1 S 2 d 3 53714 ud Salta 53113 camped JVADIH L 29207409 220722760701 226 2109 092 807 4393 3 103792760761 IVW GVLOVI 48 43844027527 GO 6 d34331NhnO2N3 103276278071 ISNIVN 13 38 38AdD0O p2Z SO tl 3131dA00 NOV ve S0 vi 11 492Vd bC S0 vl 11 aNIM34 82 S0 PL 3131AN09 AgO2 EZ SO0 vi 11 890 438 43HAdO2 22Z S0 vi 3131d 4QO AdOO Z2 S0 t 11 880 38 4HAdO2 ZZ SO v1 21314409 Addo 1274070 11188 38 4 02220740761 880 ONI M3H 1v120 000660 Yo SO 880s8 OVW gOsI N nH 6L S0 bl 880 GNIM3H 8 VO
14. H3AIMQ I Os1 NDQS 10 2O Ht gaya IM3H BS l 0092 0 ip SS l 2X319v7 1 021 NnM Op 9S EL 31214602 2 4 12094 1 ROYA 16 H3AINQ QNIA3H 9S EL S3113 O DANA roa og o YSALNO aSAIS J dHAdO2 02 9S9 1 63114 O SELEN 3 IO3 02 9S 1 H3AIHQ O190 VA 584502702 SS E 53114 0 3 NS 103 02 9961 H3AINQ v3AIUQ ZO dHAdO2 61 98 1 63114 0 GUMSLNACONS I03 61 95 1 Andifi ISNIV dgS JHAdO2 81 9S EL LELAOLSOCLMS ST 8 9 61 2015 81 95 001221 NOY OL 13 002911 0 01 011400792761 iHdd aWOSAS 20dOVW OvVWnhaO ISNIYV 0 201 09 48 SS 1 9vzv QI XIvd Pd 83AIuQ v3AIuQ duQ a8llNnusgI1 i13S01 48 SS E 1 PSO2A2 OVOl bE SS EL 0DJGNIM3H E S 5S El tos Ad02 E SS 1 09 232d20YW 38 43HAdOO ZE SS 4 0E SS 1 SAS8 139 0 SS El 1l39 92 Sg8 1 Sr V QI XIVvdsnd P80dWo SvcYVsQI XIvdsnd 20d0VW 139 PC SS EL ISNIVWsW ISNIV S 3WvN3H dANODIS T1VO ZZ SS8 0518 139 te GS 61 TSNIV 139106 5 51 X1vd 123n08d 61 SS Q31VGITVA 5 01 254 0122 6 SS EL SH 20 04211 000S2I zWO 9SpZYV G SS 1 gon GQ3LLIWANS 613SS L 6 L Z SONOHX SIND 1 11 84 022992 28762 2 1 8 1Nhn022Y pe z AWG N3d 31 8 NOILVYINWNOOWV 44 99 b 1502 1Y101 9070 52994 9070 ST1visa3lvW O T 6 6 SINI 062 6 0 553008 0 1 90 18 IOVS 4870 nud 9ES
15. a stack of size lt length gt and type type 2 SUBROUTINE START name START initializes the top of the stack name to the first element of the stack 3 SUBROUTINE PUSH lt name gt expression label expression is an expression label is a statement label PUSH pushes the expression expression onto the top of the stack name unless there is an overflow in which case control passes to the statement labelled label gt 4 FUNCTION POP lt name gt label gt POP pops the top of the stack name unless the stack under flows in which case control passes to label The type of the result of the POP is the type given to the stack in its DECLARation The required macros are much more complex than the macros of the second example but much power has been gained First stacks of any type are supported The implementation of POP in the second example constrains stacks to be of INTEGER type Secondly less parameters are needed for each invocation of POP and PUSH and the implementation of the abstrac tion need not be understood by the user Finally a fixed amount of storage is needed for temporaries in the code generated by POP This is not true of the second example The one drawback is that at most 2532 eight POPs of a given type may occur in a single statement See the example of the routine MISTAK However this limit will rarely be ex ceeded in practice Arbitrarily complex da
16. only if AINSI INDEX is false 002 OL 09 i 3N P 41 uI lli M Sd wOlid9 P M ooZz oo0r 00z p f 31 HI 1l W Sd wOiia9 n f LM M 002 01 09 Z 415 901 81 1I ONI 3dA1A dI 002 OL OD i 3N P JI CL OD p O3 f 31 1 71 64 01139 n pr 5 coz oo 00z p r 41 002 OL OD Z i9 5901 01 dI ONI 2dALA 41 002 09 1 1 dI 09 0371 41 1 M 3 s OlI dI i M Sd xOi139 1 f M OG OL OD 11 3N P 41 81 11 3 54 1134595 P YN M o8 cs o8 Cit P JI uI ll M Sd 9 O1139 n M og OL 99 p 3N D 41 O OL 09 hE 038 41 8SI 1I M Sd M01139 P M n 002 002002 002002 002 0240 002 002 002 002 002 002 002 00 002 00 01 09 11 ACLLI 5 L QNI 3S8Vd Sd A 0 2 HSA 2 4 2 2 A 27 0 589 A HSH 2 35vVn5Nv1 Hy1no3s JHA NI SI SNIHIS HSITOd 141504 SLI 4I AINO ONY 31 141825816 ISNIV 1 937 V SI NOIS S3udX3 NV 318VINVA H3031NI NV 38 A LINVI1SNOO 33931N Q3NDIS NO NY 38 2151 NOINN 310N30 ONY NOIIVNSIVONOO 310NZQ 1 AQT 1v21501 MOLLA TEALA 8 Sd GNI 5 ONIMiS4 G NLyISNIY NOTiONNA 1 21907 38 ONI as SNS S 8 SN8 QNI S 31no3axa3 I 93N30 S Of CL OD ONI ISNIV 41 X30NI ISNIV 7 931 LO
17. uv1230 sans sans 4016 060109 I X i 1vVAHO3 nP O0LI 9 311HM over L 10Is10I 101 2 0V OtO109 1 331 101 dI 2 8 V oc acvyxis11vo SNNILNOOD C I 1vo124 001 8 ozo105 0E i15 00I dI 1 001 001 01 020109 0 1901 41 I OI OI oe t 100010a 5 gt 8 HOV WOOMLIS NOVIKOO 90vNOISIO3SUa318n00 8 90v noaxi1S NOVilOO 310771721901 8 30V 901M1S N CLIO 101 SONS IYAINOA 0 0H3931NI C1208 001 39N31VA1003 41 938 30v gov 2ov gov vov eov 8BOov Zovivis 3ov agov oaoy aov vov eov 8ov LOV V3X M1S NC C 1 v ol 30N31vA nOo3 0 g VNH3O31NI gOV sov rov OV zov LOV OOV OVH3O3INI 90vV SOV vOV covV COv LOV OOV OV INIMIS NCMPUIOO SF 07 00 o 02 0001 91 SNOIi1VHNVTIO3Q SNOISNVdX3 LE 0 0 0 517101 0 0 c 18V1S 9 0 0 0 0 0 gt 0 L dOd 0 0 0 t D38gNVW 0 0 0 voz SINSWSLVLS 318v1n203X3 SIN3WWOO SHOU 3 SNOILVAIiOV NIVW 20 AMWHVWyns sans 5805 5 sans HSNd dOd dOd sans 14715 sans 18 165 sans 5915 s8ns uy 1930 sens uv1203a sans 938n08 oe N4D013M 06 020109 10 101 2 060
18. 01 41 ans ODAN 010109 17197101 41 HSNd L 1O01 101 Fn a SANS Fe 45042716 ANVW OOL xx H3Ssn HOHHS x SENS p ae ee 0 SSS a TAPER ar a a SENS Fe VIII 3 o 000000 00000 L CG a a NOIi1V38O UISN j HOU U 3 CELINE OU TT o SNOIIVMVIO3Q 8 SNOISNVdX3 0 aS 86 SIWLOL 0 0 pe 15716 0 0 0 k Sa38n03 9 o 0 2 HSAd 0 0 0 1 LZ 0 0 01 0 0 t t uvio3ad SLN3SWSLVYLS 318Vi1noO3X4 SiNIWMWOO SNOILVAIiOV Ot OVA 30 AUVMANS SNOILVAILIOV ON 103 40 19 0 v 0 8 0 6 0 0 SIN3A31VIS 318 1023 3 OOOOOOOo co S LN3WAOO T4 i 1 580883 88 SNOILVYYV1930 62 SNOI vc SFO QD Q iO SNOIiVAIIOV AMYINIINS SN dX3 S1V101 S38SAS 1 4 15 23860 dOd 238NVA TYNI4
19. 1 411922 265000 381Vd sISNIV 002 2000 NNLH 122000 i Q da3SIXNTIYO 7 820000 3nul eISNIV 001 229220009 0020109 619 901 UI IJI 5 324 1 41 06 2 2009 00601 9 08 102000 BI T11 M Sd MOl139sD 02000 102000 902700 002 9 n ar 941000 uI 11 M Sd M0113950 211000 041000 0020109 27198 901 GNI Liasxwad 951000 4 0020159 1 3 pS LOCO 050209 076 26 000 i CUI TIM 54 E 9751000 bt O00 002 09 002 6 7 31 oozoico z 15 5031 OlI dI QNI 113SXA 3dAL1A 3I 0 1000 O020109 Li 32N 1 4I 171000 069 109097927 1 31I v 10090 HI Te 4 Sd MOli39sn 021000 0141 9 54301152951 grY Y OC 014000 osoLoo 44 3N P 4I 901000 uI TI M Sd M0113D n 201000 L W H 001000 08 0p OoB L1 Pn 4I 4000 0 81 II 1395 120950 040000 0S01C5 b 3N n aI 990 C OLOD Eb Oa 41 p90 III A 1305 096000 0 btMSM OL C 950000 002408021007 002 04 00 02 0 002 09 002 002 002 002 002 002 001 002 002 06 002 0109 620020 81 IISA 56 011395 020006 41000 C QONI 2SUvVG Sq XSSVXW131y 11000 Sd A1S1XW11v5 100000 ONT JWEST XIAO 500000 100000 dSS1XW11VO 00000 2 A 9 9 A HSA 2 2 2 A 297 729 2 S gt 1 E SI SNIH1S 5 HSI10d XI4L Sod SII AJNO 41 19100591 SI NOIS 2 S3MdX3 NY 318VINVA H3D31NI NV 38 A CNY i
20. 109 317197 4 201 1 107 00 201 1 020109 31 19201 41 L Z01 Z01 1 001 001 001 8 40V 31001 AJI 1 01 00 020109 173170 1 dI O N31H3931NI SSS 12214 20103083 1 1003 N31 1H3931NI 1 23 101 329N3 1 v A1n93 N31J2H3931NI 1 8 001 39N31VA1003 N31j81v3MH C1 V or 39N31vA1n03 N31 VH3931NI Jdov sov rov Oov zov 10V OOV OVH3O31NI 9ov sov vov eovV cov Lov ooV Ov LINIMAS NOW CO 5 5 g V N31 0Qvx15S3NI1n0U8ns SNOI1V3VIO3Q 0 SNOCISNVGX3 L 0 0 L 61 101 g 0 e AFIS 0 0 077 L 8 9 0 0 c HSNd L GN3Dud 6 0 e 0 0 0 v SIN3N31V1S 318 1023 3 SLIN3WWOO SHON 3 SNOILYAIL Y QGVvMiS 40 AYVWANS sans sans sans sans sans 1 831 382 LON 2 MOVI1S 5 5 ccrNLrLNq r S QA L RR 00 V NOIi1v3ND 3lvOI1dhQ x u3sn uOdd3xx SANS l Nv31008 VOI 48v1230 x uaSn HOMH3dx SENS ea uv1ioag sans 6 5 1 n 801 39N31vAInOZ 1 nNOISIO34Sa328nCQ LOT SONSIVYAINDS i 11V3M 1 s 901 350N31YVAInO3 1 S1V38 oZzov orov ooov ZOv
21. 12 2 ds 3 function reference 13 binary 4 lt unsigned constant INTEGER gt 14 binary 5 unsigned constant e REAL 15 relational operator 6 constant e LOGICAL gt 16 AND 7 unsigned constant e DOUBLE PRECISION 17 OR 8 lt constant e COMPLEX gt 18 NOT 9 constant HOLLERITH gt 19 unary Note that function or array arguments are not further decomposed but left intact The other pieces of information contained in a token are a pair of indices which indicate the positions within the original ex pression between which lies the actual string corresponding to the token In summary a token is encoded as a triple of integers the first element of which is the token code the second is the left index and the third the right index For example the token for the array reference in the string 3 AB 4 is lt 2 2 8 gt 2992 An expression is parsed as a string of token triples in Polish prefix form hereafter referred to as a token string boundaries of the triples are not distinguished That is a string of n tokens is physically a string of 3n integers the user must break the string into triples with his code Further the arguments of a function or array reference immediately follow the reference token This is consistent with prefix notation if one considers an array a function reference as an operato on the arguments Example 6 The expression CCID ANIRE LESTE
22. C control STREX Macro File BIGMAC Compiler Macro Module Data Flow Control Flow Figure 1 BIGMAC Outline The structure of the BIGMAC system is depicted in Figure 1 At the head of BIGMAC is table driven scanner This scanner in con junction with a user programmed macro module forms a text transform ing machine macro module consists of a recognition table and a set of macro actions recognition table is an array of phrases to be recognized called the recognition domain and a function mapping each phrase into the name of a macro action in the macro module Each macro action is a program for performing a transformation on the text stream to which the scanner is currently being applied These transformations are carried out with the aid of a number of system primitives The operation of a BIGMAC text transforming machine can now be described as follows The scanner will search a submitted input in a forward scan until either 1 The end of input is reached The machine stops 2 A suffix of the text thus far scanned matches phrase in the recognition domain The associated macro action is invoked Upon return the scanner resumes where it left off BIGMAC scanner does not rescan the recognized phrase A BIGMAC user writes macro modules in a language called STREX STRing EXtended FORTRAN This linguistic framework is the subject of the second part of this manual For the pr
23. ECUTABLE STATEMENT IMPROPER MACRO REFERENCE macro name TYPE DOES NOT MATCH IMPROPER MACRO REFERENCE macro name gt WRONG NUMBER OF ARGUMENTS NAME ALREADY TYPED lt name gt BLOCK NAME TOO LONG TRUNCATED TO 6 CHARACTERS 44 Meaning Obvious Obvious End of file mark does not directly follow an END statement A program unit with no executable statements was encountered Macro is a subroutine while reference is a function or vice versa Reference has more or less arguments than the macro invoked The variable twice name has been typed Obvious 45 Run Time Errors Message Sources PASS 2 UNDEFINED VARIABLE ADDTOK ASSIGN ASSIGNI COMMENT CONCATE CTHERE DECLARE EQUALS ERROR EXECUTE FUNCTION GETTOK LABEL LENGTH PARSE RPARSE SELECTION VTHERE VTYPE A Meaning Recovery Action string variable is undefined Returns a token which has negative token code No assignment takes place No assignment takes place No comment is placed on output Null string is substituted FALSE is returned No declaration is placed on output FALSE is returned No error is placed on output No statement is placed on output Null string is the result of the function Returns a negative token code No label is placed on output f is returned Null string is the result Null string is returned Null string is the result
24. EGER I J K MANBEG B READ 5 100 K 100 FORMAT I2 DO 10 Js LK 10 J I SUM J 1 WRITE 6 200 K I 200 FORMAT 1H1 2HF 12 2H 14 MANEND STOP PRGEND INTEGER FUNCTION SUM J INTEGER 1 02 ROUBEG SOM 0 IF J EQ 0 ROUEND DO 10 1 9T 10 SUM SUM J ROUEND LRETURN PRGEND LEND BLOCK DATA COMMON IT I DATA 1 0 BLKMAC BE Legend PRGEND END xxxx Special Macro C AP SYSEND Null string AP 2192 The placement of commons in the SYSBEG macro makes those commons and only those commons global to the macro process That is the extent of these commons will be that of BIGMAC s entire execution These common storage cells can be used for global communications between macro actions For example one may wish to have a flag INMAIN which is true while the scanner is in the main routine of the input text and false at all other times Putting INMAIN in a common block in the SYSBEG macro will guarantee that INMAIN will be available to all other macros containing the common block and further that the value of INMAIN will be preserved from invocation to invocation INMAIN is initially set to false by the SYSBEG macro MANBEG macro should turn it on and the PRGEND macro will turn it off It should be noted that common variables which are strings may not be equivalenced either implicitly or explicitly 219 4 MACRO TRANSFORMATION PRIMITIVES Just as the input stream is viewed as a sequence of text
25. FALSE is returned 0 is returned PASS 2 SUBSCRIPT OUT OF BOUNDS Obvious ASSIGNT GETTOK SELECTION No assignment takes place Negative token code is returned Null string is the result 552 552 552 552 552 552 552 552 LABEL TOO LONG EXECUTE LABEL STATEMENT TOO LONG DECLARE EXPANSION EXECUTE COMMENT TOO LONG COMMENT EXPRESSION TOO DEEP CONCATE NAME GENERATOR OVERFLOW INTEGER GENERATE REAL GENERATE LABEL GENERATE COMMON GENERATE CANNOT ASSIGN AN EXPRESSION ADDTOK ASSIGN ASSIGNI BAD TOKEN BAD TOKEN LIST RPARSE Obvious Label is truncated to 5 charac ters Label is truncated to 5 charac ters Obvious Declaration is truncated to 1320 characters Statement is truncated to 1320 characters Statement is truncated to 1320 characters Obvious Comment is truncated to 77 char ters Nesting depth of concatenation ex pression is too deep Null string is the result Name generator has exhausted 11 possible names of the indicated type Generator recycles i e starts over again parameter passed by value is the left handside of an assignment Returns a negative token code No assignment takes place No assignment takes place An invalid token occurs in a token list The syntactic structure of a token list is invalid Returns the null str
26. N 51 3 08 05 09 o 31 0 441 318vIHVA AuvHOdW3l V OL SHL SNOISSY QYOVW 5 ISNIV v21501 S ONI ONIYLS QNI SNS 0112 04 SNISUIS ODN O QN3 NUAL3Y 3S1V4 ISNIV 002 Nuni3H AHL ISNIV 00 00Z 01 09 19 DOT YI TI GNY SdALA 41 06 201009 001000 SN8 d3S1XA411v2 9400C0 i0I SNE8 XxSSVXW11v2 20000 0V 1 LLI1XW QN32XW LOI 190000 ni eovvivd 190000 QNI QINOXW11YO 950000 20 6 1 111XW 939 po 1192 0 190000 Hi 8uti eovviva 90020 48600 SN8 a3S1XN11V2 6600 0CI SN8 XSSYXW11VO 60000 CLOovV ED 2IAXW GN32XWz001 C000 Hi tovviva 920000 S 0000 oov 2 L119 Ke DIGOXWTI1V9 0 000 H i 00 1 0 0 00 0 01 0 23 3 1 2 920000 QNIJ GN3OXW 0I 260000 COv 1 2 LIAXW OINOXW11VO 920000 f 04 1 0 920000 s o389XA11VO 2 3N35XN S XSSVXW11V2 2 0000 CLOLOO GNIJISNIV AI EFOOCC S A1S1XW11vO 0000 QNI UudS xu11v2 200000 SNB S1XN11y2 00090 u 200020 dSS1XW11VO 00000 5 ISNIV 19931 V LON SI 2 31 441 318vISVA AXVHOdWAaL V 01 0 3 SNOISSY 0829 SfHl 9 2 f ISNIY1V21501 00000 S GNINSO31NI 00000 OVHSDRINI 000 00 4 2 4 8393 4 100 39Yd LL AON NOISH3A 0 436
27. N31 WOVLS 1 dA11 3UuV1030 9 SOIISIHN310VHYHO 1NVA3138 511 NIVI3HM ONY 3 371030 9 2 1S10 8 1SN31 0 1S30 1612 816 317 0 1612 3uv19030 1 1519 1519 LE 1 1510515719 1 I 1 8yvA1 3 39 1 amp i I 00 770 1 4 1 SHLS NOWWOD 1S19 1 dA1121S30 3081 7 1 9NIL Or OL OD 3 O9NII1 41 OE 2 06 OQ NI Q30035NI N338 13A LON SVH MOVLS 381 40 SHL 804 NCWAOOS ANvHOdWi1l SHL dI 9 5 1 1 1 93111 uONH3 12 3nNI1NOO 031561 Si 39VSS3W 0 82 NV HONS3 1 1230 ON 051 SI 8 dI 70354011384 SI 0 51 3 LON 300 11 4 MOViS 3WVN MOvl1S 1 30 3002 83931 3H1 3NIWBS313Q DE 16 ONIHMIS YUVAL ONISNIS ONIL NivANI uH32030 1V21501 162 01964 1 010514 0135821 51 S ONIL S dAL1 S QNIL1 8 G HVAL NIVANI3822938 1 NOWWO MOV1S HO HM NOILONAS 1 1 1 S S 3ino3X3 67 WOWLS dOd 31no3x3 140Nn 0109 17317 S 418 31n03X3 1 6 1 55 b V GNIL 87637 41 b P VIGNIL 90 1 G8NI12sP 1 SdA1 1 Nu nidq8 070321 dI MO2VIS HOIHM I 3 32 393343 4 NOILIONDd SHL 8034 3 1 11153 5 SI 3VVN 8 1 541220 MO1383GNf NV 41
28. NOWWOO AYVHOdWSL 3Hl 3SUV 03G ONY 13538 O3NNVOS N338 1517 SVH 3NIi1nOSN NIVW 3H dI S M1SO SdAL QONIL H3931NI SUuld SN31 SUVN dALL HVAL 5 2 ONIL NIVANI u4323Q0 1 21901 y1S2 01 SdAl1 COL 5 14 OLISNSTS 01 YSWYN S ONIL1 S dA11 8 S 8VAI NIVWNI u332030 104416 QN39Hd 3NII1nON8hS OMOVM O O OOO O GQ CG O O S M1J8AQ W31I MOVI1S SNISIS MLSO SdAL GNIL 83931NI SSid SN31 SAVN dALL WHVAI ONTYLS ONIL MIVANI uH323Q0 1VOI901 y1SO2 01 SdA1 01 SHId O1 SN31 OL SHVN 2 1 6 4 11 6 11 8 S YVAL NIVANI HH2230 15 NOWWOO M14MAO W311 MOviS HSnd ANILNONSAS 2 5 Nuni3u i I SMid 31023X3 3 0 O3 I 41 22 MOVIS HOIHM I 2 1N3W313 2 16 15814 2 JHL OL 401 2 16 3 1 5 2 HOIHM 3000 3iYH3N39 OU3Z NON dI 2 2 15 3WVN 3HL HLIM 2 16 3 MOd 3000 8S3931NI JHL 3NIWH3130 9 2 HOIHM 33931NI 2 16 ONIHIS M41SO SdAL QNI4 N3931NI SHId SN31 SVVN dALL HVAL 5 ONIL NIVANI uua3230 1 21901 ISO 01 OL SN31 OL 2 2 s oNI1 S aA11 e aNI1 8 S 8VAL NIVWNI 8 3930 10dXM1S NOMIAOO WOWLS LYVLS 3NII1DON8nS 2 2 0 3 138 C1 WOVLS M1SO SMId 130 31 1003 3xv193a0 1 11502 8 1 I u3N39 M1SO SH1d N31 2 M1S9 SN31 MOV1S MISO SHVN 6 6
29. SAd 1172 1230 1192 8n00 8v1230 11v2 ly3H uHv1030 11v9 v3H Hy1230 11 2 INI HuV1O3Q 11 2 INI uy1030 11 2 1901 4v19030 11v2 30 11v2 i xd 1V9 2 15 15 1172 Op V H39O31NI NY103Q 11v2 0Z M N 31008 Hv123Q T0 O0g V H3O3INI Nv103Q0 1Y9 ANILNOYENS NH 1l3H 06 E x Kr otis gt L ov 02 01 09 og tog i dOd 2 HSnd TIVO oe OL OD 0 07 S dOd O0Z V dOd L IHSNAd 1192 L iMViS Tivo D LYvVLS 11 2 3141483931 1 8 1230 11 2 N31 9 83931NI 3Uv19030 YD 11v2 N31 V H3531NI 5v1230 11 2 N31 9 2 g v Na1 aavMis 3NILNOYSNS 4015 Ot 0 OL 09 LI X1 l1VWS803 001 n 001 9 3118UM 2 404 06 02 8 v oge aavw1is 11 2 oc OZ Z I ivOl1d g HSnd 11 2 01 oZz I v HSnd 11 2 OL 8 149V1S 11 2 V 1uV1S 11VO 0 2 u3931NI uv103Q0 TVD 0g a 1V3u uvlo3d 11 2 og V Su3931NI uv123Q 119 sans 938546 5 L SNOISNVdX3 0 0 0 L 61 101 ERES ES 0 0 0 L 85 5 SINSWSLVLS 318 1023 3 SLIN3WWOO Soy SNOILYAIL V Ol OVW 358 40 sans sans dOd sans HSnd sans HSfid sans LYVLS 5975 18 15 sans uv123g sans
30. STREX MACRO LANGUAGE ups PRELIMINARIES STREX STRing EXtended FORTRAN provides the linguistic frame work for programming BIGMAC macro modules Formally STREX is a superset of a subset of ANSI FORTRAN Section outlines the relevant subset of ANSI FORTRAN other sections describe the superset in three parts pes ee String data type concepts N Macro concepts 3 Macro module concepts Throughout this part of the manual there arise many occasions to reference the ANSI FORTRAN Standard ANSI X3 9 1966 Such references 111 be abbreviated to 115 5 of section numbers square brackets An extended version of Backus Naur Form qrammar rules will be used to describe the syntactic form of STREX features Nonterminals will consist of a description of the token surrounded by angle brackets e g variable reference Terminal strings will be enclosed in single quotes e g DO A plus sign will be used to compress several rules having the same left hand sides e g A lt lt B gt lt C gt z A lt B gt A lt C A superscript star will denote zero or more repititions e g lt A gt lt B5 lt A gt lt A lt B gt Curly braces will be used for bracketing purposes e g A lt lt B gt lt gt lt lt A gt lt D lt A gt lt lt B gt C lt A gt 218 In STREX FORTRAN there are six different kinds of data types o
31. THE BIGMAC USER S MANUAL by Eugene Myers Department of Computer Science University of Colorado Boulder Colorado 80309 CU CS 145 78 November 1978 This work was supported by NSF arant MCS77 02194 and Army Grant DAAG29 78 G 0046 I II III TABLE OF CONTENTS SYSTEM OUTLINE O Z O Uu OVERVIEW du sQ SCANNER RECOGNITION COMPONENT SCANNER TRANSFORMATION COMPONENT MACRO ACTION SET STRUCTURE MACRO TRANSFORMATION PRIMITIVES NAME GENERATION AND EXPRESSION ANALYSIS THE STREX MACRO LANGUAGE PRELIMINARIES FORTRAN BASE STRING FEATURES 1 String Declarations 2 String Assignments 3 String Expressions 4 External Functions MACRO FEATURES 1 Transformation Primitives 2 Unique Name Generator 3 Expression Analysis Primitives 4 Environment Primitives MACRO FILES APPENDICES SCANNER TRANSFORMATIONS ERROR MESSAGES BIGMAC ON THE C U CDC 7600 SAMPLE APPLICATIONS DH 17 19 20 21 22 24 27 28 29 3l 32 36 39 40 42 48 50 I SYSTEM OUTLINE 0 OVERVIEW The BIGMAC system is a programmable utility for performing textu al transformations on ANSI FORTRAN code BIGMAC was developed for the specific purpose of replacing procedure calls with in line code For the purposes of modularity and hierarchical development it is frequent ly desirable to code simple routines for low level data abstractions
32. ced only by DO statement Case 1 1 DO terminal statement is an N statement DO DO label loop DO amp lab loop AMAN lt 00 1 1 gt lt N statement gt amp lab lt N Statement gt Case 1 2 DO terminal statement is A statement DO lt 00 1 gt loop DO amp lab lt gt D0 label lt A Statement gt lt A Statement gt amp lab CONTINUE Case 2 DO label is referenced by a statement other than a DO statement DO lt 00 1 gt lt loop gt DO amp lab loop D0 label lt Statement D0 label Statement amp lab CONTINUE Conceptually the solutions for 1 and 2 be applied in parallel However some inefficiencies result Consider then that case where a DO terminal statement is also a logical IF re quiring splitting The appropriate DO transform is applied either case 1 2 or 2 above and then the following abbreviated transform is used for the logical IF statement IF lt expr gt lt A statement gt we IF NOT expr TO TO amp lab lt A statement gt Where amp lab is the same as that used in the DO transform The reader is now referred to example 2 in the first part of this manual ADs B ERROR MESSAGES There are two phases to using BIGMAC One first compiles a macro module using the STREX compiler and then one uses the compil
33. d 40 lines second The second step is carried out by the procedure BIGMAC which has three parameters GET BIGMAC PJ PAIX ID A246 CALL BIGMAC RENAME M I B The M parameter must be the name of a macro module created by BIGCMP above The I parameter is the AINSI FORTRAN text to be expanded and the B parameter is the result of the expansion This step requires 100 plus enough extra core to fit the object modules of the macro mod ule The processing rate is 60 lines second plus the time spent in the macros themselves 49 diagram below summarizes the steps Macro File BIGCMP Text File Expanded File 50 D SAMPLE APPLICATIONS Three examples will be given below The computer printouts for each example consist of three segments in the following order 1 The macro file for the example 2 The input text to be expanded by 1 3 The BIGMAC listing of the expansion of 2 by 1 The printout for the first example also contains the object code FORTRAN for the macros in the macro file and the day file for the job The first application illustrates the usage of the parser and en vironment primitives An auxillary macro AINSI INDEX takes the expres sion INDEX and determines whether or not it is a legal AINSI subscript expression function macro BNS INDEX replaces itself with a refer ence to the INDEX element of an array B BNS assigns the index to a temporary variable if and
34. d as array name within the program unit Example 8 Text Macro SUBROUTINE EXAMP COMMON A X Y Z 3 T FUNMAC J END STRING FUNCTION FUNMAC S STRING S LOGICAL CTHERE VTHERE L 7 INTEGER VTYPE DECLARE COMMON B R S T 3 L 1 CTHERE A L 2 CTHERE B L 3 CTHERE A L 4 VTHERE T L 5 VTHERE A I VIYPE T L 6 VTYPE 2 L 7 I2 END 25s When the macro FUNMAC is invoked the values of L 11 12 will be TRUE FALSE TRUE 3 39 y MACRO FILES A STREX macro file is a file or other line oriented text stream consisting of a number of MACRO lines and STREX program units termin ated by a line containing a dollar sign in column 7 STREX macro file is a complete specification of a macro module A MACRO line is a line containing the phrase MACRO in columns 7 through 11 These lines must occur just before a program unit They indicate that the following STREX routine is a primary macro action The name of the routine is put in the recognition table along with its type subroutine or function and the number of arguments it requires The formal parameters of such a routine must all be simple string variables and if the unit is a function it must return a string value Any routine in a macro file with the name SYSBEG PRGEND ROUBEG SYSEND MANBEG or ROUEND BLKMAK MANEND must be a primary action which is a subro
35. e For classes 1 through 3 each invocation of the qenerator returns identifier of the appropriate type which is unique with respect to those of the program unit currently being scanned and those generated since the program unit s first character was traversed For the class of block names an invocation produces an identifier which is unique with respect to all the common block names in the input file and those generated thus far See the GENER function in the second part of this manual A parser for FORTRAN expressions is provided primarily so that a user may analyze the arauments of a macro action For example one may wish to determine if an argument is a simple variable or a valid subscript expression parser will produce post fix polish parse strings which may be examined and modified by the sophisticated macro writer via the string manipulation components of the STREX lanquage Any well formed parse string may then be requested to yield the string it derives i e the reverse of parsing See the functions PARSE GETTOK ADDTOK and RPARSE in the second part of this manual The BIGMAC user may also examine the environment surrounding a macro activation phrase One may inquire as to the existence and usage of common block and variable names in the input text proce dure containing the activation phrase of the current macro invocation See the functions VTHERE CTHERE and VTYPE in the latter part of this manual II THE
36. ed macro module to expand some input text Errors are detected at both stages STREX compiler s error checking is not very extensive It basically only tries to insure that the string and macro compo nents of STREX programs are properly translated The compiler error set is listed below in the section entitled Compiler Errors The errors that occur at the time a macro module is applied to a stream of text are somewhat more extensive There are two classes of such errors The first set of errors are those that arise when the input text is found not to be ANSI FORTRAN code Text Errors The second type of errors are macro routine errors trapped by the BIGMAC interpretive primitives They involve such items as undefined variables and subscript range errors The semantic action in progress when an error is detected is given in parentheses along with the error message A corrective action is taken by the primitive and processing continues The specific recovery actions are given in the list below Compiler Errors Message Meaning NAME TOO LONG lt name gt The variable lt name gt is more than 6 char acters long LABEL TOO LONG label The label label is more than 5 charac ters long END OF FILE An end of file mark was reached while still in the middle of a macro NO EXECUTABLE STATEMENT A program unit with no executable state ments not even a RETURN was encoun tered NO SYSBEG MACRO At least one common was used i
37. esent it suffices to know that there is a system compiler for transforming STREX specifica tions into macro modules ly SCANNER RECOGNITION COMPONENT The BIGMAC scanner can recognize any subroutine call or function reference in an input of ANSI FORTRAN code To specify a particular routine invocation for recognition a user just gives the name of the routine Furthermore a user restricts the admissible syntax of recognized invocations by indicating 1 whether the routine is a subroutine or function 2 the number of arguments in the invocation If the scanner recognizes an invocation which is not admissible i e violates either 1 or 2 then a message is issued and the associated macro is not invoked An activation phrase is the text of a recognized and admissible invocation More explicitly in the case of a function reference it is the text from the leftmost letter of the routine name to the right parenthesis ending the list of actual arguments For a subroutine call it is the text from the C in CALL to the end of the line i e it is the entire CALL statement The rule for associating an activation phrase with a macro action is particularly simple The name of the routine in the activating phrase is taken to be the name of the macro action to be invoked The actual arguments of a particular invocation are passed to the macro action as text strings For function references the associated macro returns a string which i
38. fragments so is the output of the system These fragments are also of four kinds 1 Comment An ANSI Standard comment line 2 Label An ANSI statement label 3 Statement An ANSI statement 4 Error An error message These messages are printed out but do not occur in the final BIGMAC output The output sequence is built by appending fragments to the right end of the current sequence These fragments are appended by the scanner and also the user via the text transformation primitives The scanner traverses the input in a forward scan Every input fragment is appended to the output sequence after the scanner has traversed it Thus if the scanner detects any errors while traversing a fragment then the scanner s error message fragments will preceed the fragment as the scanner appends the error fragments first Similar ly for A statement fragments the scanner will first activate all the associated macro actions before the resulting neutralized A statement is appended as a statement fragment Hence if the macro actions append some fragments then these fragments will immediately preceed their respective neutralized A statement fragment Thus the necessity and utility of the A Statement Condition The text transformation primitives allow the user s macro actions to append any of the fragment types onto the output sequence There is a primitive for each type i e the COMMENT LABEL EXECUTE and ERROR statements of STREX described i
39. ing 47 The pneumonics for the source of the errors are indicated below by giving section and item numbers ADDTOK 3 3 3 FUNCTION 2 1 2 ASSIGN 2 2 1 GENERATE 3 2 ASSIGNI 2 2 2 GETTOK 3 3 2 COMMENT 3 1 1 LABEL 3 1 2 and 6 CONCATE 2 3 6 LENGTH 2 4 1 CTHERE 3 4 1 PARSE 3 3 1 DECLARE 3 1 5 RPARSE 3 3 4 EQUALS 2 4 2 SELECTION 2 3 5 ERROR 3 1 3 VTHERE 3 4 2 EXECUTE 3 2 4 and 6 VTYPE 3 4 3 The one pneumonic which cannot be described this way is EXPANSION which is the action of substituting an A statement fragment by its neutralized counterpart 48 C BIGMAC ON THE C U CDC 7600 Using the BIGMAC system takes two steps The first is to try to compile a STREX macro file into a macro module A macro module is a multi record file consisting of three object modules and one data re cord These modules and data when combined with the rest of the BIG MAC expansion component implement the macro process specified by the STREX file Applying this processor to some AINSI FORTRAN text file constitutes the second step In terms of KRONOS control language the first step takes the form GET BIGCHP PJ PAIX ID A246 CALL BIGCMP RENAME S M The S parameter is the name of the STREX macro file and the M parameter is the resulting macro module This step requires 125K and depending on how heavily the string and macro features of STREX are used compiles code at a rate between 5 an
40. n the macro file but none were declared in a SYS BEG macro TOO MANY MACROS The STREX compiler s internal structures have overflowed not likely to happen DUPLICATE MACRO macro name MACRO ARG NOT STRING ILLEGAL SPECIFICATION name SYSTEM COMMON NAME common block name IMPROPER STATEMENT STMT ILLEGAL HERE ILLEGAL EXPRESSION AT lt number gt lt type code 43 name with the name macro name is de clared more than once All macro arguments and macro functions must be declared to be STRING The variable name has been given con flicting type attributes in different type statements Certain common block names are used by the system and must not be used by the user They are BUFP CONCAT GLOP ICFILE LEXIC LIF LISTE MACSAR MFLAGS PTR PTRS SYST TABLE WRKKEY The compiler cannot make sense of the statement A statement is out of place e g a de clarative statement following an ex ecutable one The expression is ill formed The erpor was first detected at the number gt character of the expression and at that point the expression was of type type code where the code is N S no type STRING INTEGER REAL COMPLEX DOUBLE PRECISION LOGICAL Text Errors Message NAME TOO LONG TRUNCATED TO 8 CHARACTERS lt name gt LABEL 700 LONG TRUNCATED TO 5 CHARACTERS label END OF FILE NO EX
41. n the second part of this manual Each primitive takes a user constructed string and regardless of its syntax appends it to output as a fragment of the type specified by the primitive Any sequence of these primitives can be executed A critical feature of BIGMAC is that it places a CONTINUE statement fragment between any two consecutive label fraaments This is semantically natural if one considers a FORTRAN in which statements can have any number of labels Along the same lines if the right most fragment of the current output sequence is a label fragment and one is about to append either a comment or error fragment then this fragment is not appended but placed to the immediate left of the label fragment This quarantees that the label will refer to the next statement frag ment appended and again is semantically natural if one considers a FORTRAN in which comments can occur arbitrarily within the code These two precautions insure that if a user aenerates syntactically correct fragments then the result of appending an arbitrary sequence of such fragments is also syntactically correct The above mechanism only allows the insertion of text into pro gram parts as activation phrases only occur in program parts This implies that a user has no way of insertina specification statements into a program unit This situation is alleviated by a special prim itive which allows a macro action to insert statement fragments just before the fi
42. ollowing sections The BIGMAC scanner recognizes a number of special activation phrases These phrases are provided to coordinate macro actions with respect to the program structure of the input text The macro actions which correspond to these phrases have been given special reserved names They must be subroutines with no arguments We have in tabular form Macro Name Activation Phrase AP Substitution for AP SYSBEG Empty string just left As for a subroutine of the first character in input file SYSEND Empty string just right As for a subroutine of the last character in input file BLKMAC Empty string just left Empty string of the first character in the END statement of a BLOCK DATA program unit contd Macro Name MANBEG MANEND ROUBEG ROUEND PRGEND zd S Activation Phrase AP Empty string just left of the first character in the first executable statement in a main pro gram A STOP statement in a main program Empty string just left of the first character in the first executable statement in a subprogram A RETURN statement in a subprogram An END statement in an executable program Substitution for AP As for a subroutine As for subroutine RETURN Example 4 contrived program below has been annotated to show the points where the special macros would be invoked if present in the action set SYSBEG COMMON IT I INT
43. r acters 3 1 what follows a string value will be written as its sequence of characters surrounded by vertical bars Blank characters are Significant The convention is adopted that the th character of a string value is the i counted from the left The length of a string value is the total number of characters in its sequence Example 1 STRING denotes a string value whose 3rd character is S and whose length is 8 The string data type is supported in STREX by the addition of constructions for declaring assigning and manipulating string data These constructions are described in the following subsections STREX s string component is implemented in an interpretive fashion This allows the semantic routines to trap run time errors such as an attempt to use an undefined variable in an expression or an out of bounds subscript However a semantic error of this sort does not halt execution error fragment is issued some conservative recovery action is taken and execution continues the semantic descriptions that follow error conditions are only noted For a detailed description of the errors and their recovery actions see Appendix B Em 2 17 String Declarations Type statements are defined in section 7 2 1 6 of the ANSI Standard In STREX type statements can also declare simple variables and arrays to be of string type according to the syntax la type statement lt STRING lt declaration gt
44. r modes INTEGER 4 2 1 COMPLEX 4 2 4 REAL 4 2 2 LOGICAL 4 2 5 DOUBLE PRECISION 4 2 3 STRING The term STANDARD will denote all the modes except STRING In many cases the mode of the datum that a nonterminal will yield upon seman tic evaluation must be specified This will be done by writing lt e TYPE which specified that the nonterminal A when evaluated will yield a datum of mode TYPE 2165 ly FORTRAN BASE The subset of ANSI FORTRAN that constitutes the base of STREX FORTRAN consists of all FORTRAN constructions which do not involve any of the forms listed below 1 READ WRITE REWIND BACKSPACE ENDFILE statements 7 15 31 2 FORMAT statements 7 2 3 3 Hollerith constants 4 2 6 5 1 1 6 7 2 2 8 4 2 The primary purpose of a macro action is to transform the input stream on the basis of the parameter strings passed to the macro by the BIGMAC scanner These side effects are handled entirely by the text transformation primitives of STREX see section 3 1 Hence 1 0 statements are not necessary STREX s string capabilities supersede the need for Hollerith constants 20 2 STRING FEATURES Due to the text manipulative nature of macro processing the notion of string data is fundamental ANSI FORTRAN is very weak in this regard STREX must and does provide a more powerful linguistic medium for expressing string manipulations A string datum is defined as an ordered sequence of FORTRAN cha
45. rming primitives see section 4 Henceforth the dis cussion of the input sequence will always refer to the precon ditioned input sequence Those interested in the exact transforms employed are referred to Appendix A Example 2 Suppose SUB is in the recognition domain original text on the left is transformed by the scanner into the text on the right Original Conditioned D 101 1 3 DO lt 81 gt I 1 3 DO 20 J 1 4 DO 82 J 1 4 F I EQ J CALL SUB I IF NOT I EQ J GO TO 83 F I EQ 3 60 TO 10 CALL SUB I 20 IF J EQ 4 CALL 508 4 amp 3 CONTINUE 10 CONTINUE IF I EQ 3 60 TO 10 IF NOT J EQ 4 GO TO 8 amp 2 CALL SUB 4 Legend 8 amp 2 CONTINUE amp i A label guaranteed to be 10 CONTINUE unique with respect to those already in amp l CONTINUE the proaram unit con taining it In section 0 it was stated that the scanner activates a macro as soon as an activation phrase is reached This implies that if a number of function references are imbedded in an expression then they will be recognized and activated in the order that they would be reached by a left to right post order traversal of the expression s parse diagram Example 3 illustrates this Example 3 Assume the recognition table of Example 1 Then in the statement CALL K L M I J M I L J the scanner will activate the macros in the order in dicated on the parse tree below Z js 9
46. rst specification statement an executable statement if there are no specification statements in the program unit containing the associated activation phrase The location for insertion is referred to as the declaration insertion point DIP of the program unit See the DECLARE statement of STREX in the second part of this manual Example 5 Assume the recognition table of Example 1 Moreover assume that each macro action executes the sequence of primitives Macro Name Action Sequence M lt Spec gt lt Comm gt L Stmt Label K lt Label gt lt Stmt gt 215 The preprocessor will transform code as illustrated below SUBROUTINE SIMPLE I J SUBROUTINE SIMPLE I J DIP Spec M gt 10 CALL K L M I J M I L J lt 5 gt RETURN lt Comm M gt END 10 lt Stmt L gt Label L gt Stmt L Comm M Label 1 2 2 CONTINUE Label K gt Stmt K gt RETURN END Legend X denotes the jh activation of X Ya GENERATION AND EXPRESSION ANALYSIS A generator for symbolic names and labels is available to the BIGMAC macro writer The generator distinguishes four classes of identifiers as follows 1 Label An ANSI Standard statement label 2 Integer Name An ANSI symbolic name whose first character is one of the letters I J K L or N 3 Real Name An ANSI symbolic name which is not an integer name 4 Block Name An ANSI symbolic nam
47. s NI Q3N91 3 NA NV 38 2 i31 NOIN 31ON3Q NOI 10 32 131 9 50117231501 00000 M01135 3SdALAN3DS31N Sd QONIN39231NI 00000 3ShV4J353S3iNI 00000 0 1216 12 03 21501 00 3994 4711 8 50 LL NOISH3A ONG 962000 Nuniat pEC000 200 39Vd 60 LL AON NOISH3A NAY I SN8 0 5 8 I SN8 5 CI E SNE 6 7 SNS 9 5 8 E SNE 1 5 tt NON MON SMS ui i 111 8 u3531NI Annaa 3N113088ns sans SN8 sans SN8 sens sans SNg sans SNS sans SNA sens SNS sans SN8 sans SNE QN3 Nunia3d Z I 6 82M I Z s 0I 41 82M COI B8 M V b 2Z0I 1 6 8 101 8 2M 10 85 8 5 D 001I 01 8 P ISOI EE1 883931NI AWWNGSNILAOYBNS 6 SNOISNVdX3 5 0 0 6 S1V 101 RR S 0 9 26 i SNE SANSW3SLVLS 318VinO3X3 SLIN3A WOO SYOUN A SNOILYAIL Y OYOTW AWANG 340 AYVWIANS SNOTLYAILOV ON 103 40 AUVWIANS 6 e G SIN3W31VlS 318vino2axa 0 9 S INZWNO2 in w rx SNOISNYGX3 5717101 f 6 SN8 SNOILVAIIOV QOTA AHVAWNS 1VNI3 aaa MEY 17120 3 191920 3841 381 88y 8 000550 SE rO Hs
48. s substituted for the activation phrase For subroutine calls the activation phrase is deleted Example 1 Suppose a user has specified the recognition table Macro Name S F of Args K S 2 L F 1 M F 2 0 10 10 The action of the scanner with this recognition table is illustrated below CALL K lt L gt 1 3 E Legend Activation Phrase Actual Argument Result of Macro X Invoke X 2 SCANNER TRANSFORMATION COMPONENT The BIGMAC scanner views an input text stream as a sequence of text fragments There are four types of fragments 1 Comment An ANSI Standard comment line Label An ANSI statement label N Statement An ANSI statement containing no activation phrases 4 A Statement An ANSI statement containing at least one activation phrase Note that these fragment definitions will unambigously partition any in put stream of ANSI Standard code The BIGMAC scanner is unusual in that before invoking a macro action it transforms the input fraaments so that the following condition is satisfied A Statement Condition The placement of a text fragment just before an A statement fragment in the transformed input sequence must guarantee that the fragment is executed just before the execution of the A statement fragment This preconditioning of the input considerably simplifies the requir ed text transfo
49. sion The second assignment form stems from the requirement in general string manipulators of being able to replace substrings of a string STREX uses the syntax 2 assignment statement lt lt variable reference STRING gt e INTEGER expression c INTEGER eSTRING gt lt expression lt expression The semantics of this statement are somewhat involved If the refer enced variable is undefined or is a parameter satisfying the condition given in the paragraph above then an error is issued Now suppose the variable is bound to a string datum S that expression evaluated to L and expression evaluates to R If L lt 0 or R gt length 5 1 or L gt R then an error occurs Otherwise the substring lying exclusively between the Lth and Rth characters of S is replaced by the value of expression Example 3 Value of SVAR 23 1 SVAR AVAR 2 SVAR 0 1 3 SVAR 1 3 AVAR 4 AVAR 0 3 SVAR AVAR Value of AVAR undefined initially ABC after 1 ABCABC after 2 AABCCABC after 3 n after 4 AABCCABCC 9 2 3 String Expressions The syntax of STREX string expressions forms a simple 3 level precedence grammar Level 1 expression e STRING lt term STRING lt term STRING gt Concatenation Level 2 term STRING primary STRING expression e INTEGER expression e INTEGER gt
50. ssion EXECUTE expression 31 3 27 Unique Name Generator The BIGMAC unique name generator is a STREX supported explicit function whose result is a unique name Formally expression e STRING lt GENER type type lt i TT IR The type argument specifies which class of name is being requested according to the scheme L Label I Integer Name R Real Name C Common Block Name If it happens that the generator has exhausted all the possible names within a given program unit it probably never will then an error message is issued and the generator starts to recycle through the names for the overflowing class 2255 3 3 Expression Analysis Primitives In order to syntactically analyze an expression one must have the information provided by a parsing structure parse tree is too com plex a structure to support For an expression its Polish prefix form conveniently conveys its structure in a one dimensional form Additionally the Polish representation can be encoded as a string of tokens thus allowing one to examine and modify it with the string manipulation features of STREX The components of a FORTRAN expression are grouped into a num ber of tokens Each token has a unique integer code The tokens and their codes are Operands Operators Code Token Code Token function or array reference argument 10 1 simple variable 11 2 array reference
51. such as stacks and lists However it is undesirable to pay the runtime costs of parameter passing and routine linkage for such frequently in voked routines BIGMAC remedies the situation by allowing one to pro gram and develop a prototype of the modular variety and then produce the efficient production code by transforming the prototype with BIGMAC The degree of speed up will depend on the machine and compiler in question a recent large scale application BIGMAC speeded up the DAVE system by 47 BIGMAC can of course be used for conventional macro applications greater interest is that BIGMAC is general enough to enable the programming of limited language extensions The design of BIGMAC incorporates many of the principles found in typical macro facilities It is rather unusual in that macros are not templates for textual substitution but are executable routines This very dynamic approach affords a great deal of flexibility with low de velopmemt overhead as an existing language can be used as the basis for the macro language The base language provides conditional execu tion and local and global data management The developer need only con cern himself with the macro system interface However in the case of a language with weak string capabilities e g FORTRAN the designer must also bolster the base language s capabilities in this regard BIGMAC macros are routines written in such an extension of FORTRAN Legend Data
52. t 51 The second example is a simple implementation of the procedures POP and PUSH Each macro requires a large number of parameters The user must be intimately connected with the code produced by the macros in order to use them correctly Nuniaq WILT 6 X3GNIS MOVLS 31023 3 M14NAO 50109 9 31 19 X3QNIS 9 41 31no3x3 1 X3QNIS X3QNIS 310203X3 15 40 3215 3H1 824 NOISS3HdX3 NV 28 1500 3 ONY YSLNTOd 401 WOVLS 3Hl 38 LSNW X3Q NIS 3SIMM3HIO HOVLIS 3Hl OINO W3ll S3931NI 3 539504 HOIHM 5 01443 0 MOV1S WOVLS 3 1 31 14 8 0 138 1 JHL Ol S3HONVM8 HOIHM 3009 S3i1V43N39 OSOVW M143HAO ONZ31 W311 X3Q0NIS MOVI1S 5 M1JHAO S5N31 W3lIi X3O0NIS OvVl1S HSDhd SNIANONSNS ONO VIN E 1 XJONIS X3QNIS 31 3 3 XSONIS WOWLS 31ND3X3 M14O0Nn 50109 07317 XSGNIS dIS 1023 3 I HM3N39 dOd H31NIOd WOVLiS 5 X3Q0NIS 351 M3Hl0 MOVIS JHL 5404 HOIHM LNG SMO143H3GN MOViS MOVIS JHL 41 130 138 1 JHL OL S3HONVH8 HOIHM 34202 S31VH3N3O OYOVW MISONO X30NIS M2v1S 9NIUIS M130Nn X3QO0NIS MOV1S dOd NOILONAA ONIHIS ONOVW oo OQOOOO 38 02 OL OD Of NST OESLISL dOd OI O HSNd 11 02 01 OL 09 u lI 94 0 ti II N31 1
53. ta abstractions may be implemented by BIGMAC The limiting factor is the coding effort NunliasN 93gnoOs 1Y2 3S1V3 NIVANI G3NNVO2S 38 Oi 1 08 SI ANILNGY NIV 3 N3HM 135 SI NIVANI M1S2 SdAL QNIL H3931NI SHId SN31 SUVN dGALL HVAL ONTYLS ONIL NIVUHNI4H3230 1Y21501 152 01064 1 0126414 012368314 OL SAY S ONII1 S dA11 S ON11 8 Sg HVAL NIVANI uSsia2030 10dM1S NOWWOO 3 8 NMH 138 3S1Vd CI ONTIA Ch V3J 3832 id 0 415929 038 1230 N338 SVH 3dAl 30 MOVLS ON ONV Q34H80220 3AYH SSOHN3 NO ILIVESVIOS3Q ON O34v103Q0 N338 3AVH SMOViS ON LINN WYYSOYd dO 8 5 LV MiSO SdAL QONII N3931Ni SHld SN31 SUvN GALL YUVAL 5 3430934 1 219017 1152 01 59 01368414 01968317 OL 2 S ONI 2 S dA11 S GNIL 8 S HVAI NIVNNI343230 10dM1S 538608 3aNIInO5N8S QuoVviN QN3 Nuniayg SXIIdNOIS S dALL NOISIO34d318nOQ bP dALL 1VOISO01 dA11 1v34 2 C dALL SHADZLNIG CLI GALL NIVINI b CT JONI 1 O of 3Sn 804 dN SI 40 1 15814 JHL ONV G3NNYOS 9 38 LON SI NIVN 3Hl 74 11 HO103A SHL 321 lVILINI MLSs 9 SdAL ONII MJO3JINI SJ1d SN31 DM YVAL ONTYLS ONIL NIV u4323Q0 1 21901 M1S2 91 SdAl1 CoL SH1d
54. ut parameter which should be a valid token code ACTSTR is an input string which should represent an instance of the token specified by TOKCOD EXPSTR is used for both input and output ADDTOK returns a token triple whose code is TOKCOD and whose index pair delimit the string ACTSTR ADDTOK has the side effect of append ing ACTSTR to the end of EXPSTR i e EXPSTR EXPSTR ACTSTR 4 STRING FUNCTION RPARSE TOKSTR EXPSTR STRING TOKSTR EXPSTR TOKSTR and EXPSTR are both input parameters TOKSTR must be a token string for which all index pairs refer to locations in EXPSTR hence the necessity for the EXPSTR argument in ADDTOK The result of RPARSE is the string derived by the token string TOKSTR i e RPARSE performs the reverse of the action of PARSE Token strings are strings of integers not characters Thus although one can manipulate token strings with STREX string features the user must be careful not to apply any features which actually examines the value of a cell in the string e g lt expression gt or EXECUTE lt expression gt Of course one shouldn t mix strings and token strings 2352 Example 7 The function REPL replaces all occurrences of the variable LEN with the constant 9 STRING FUNCTION REPL EXPR STRING EXPR TOKSTR TOKSTR PARSE EXPR K LENSTR TOKSTR 3 IF K EQ 0 GO TO 20 00 10 I 1 K IT GETTOK TOKSTR I M N IF ITOK NE 1 GO TO 10 IF NOT EQSTR EXPR M N LEN GO TO 10 TOKSTR 3 I 3
55. utine with no arguments Recall that these are the names of the special actions discussed in section 3 of the first part of this manual III APPENDICES 40 y SCANNER TRANSFORMATIONS In section 2 of part 1 the A statement condition is presented In order to meet this condition it suffices to insure that 1 Each A statement is a basic block 2 Any label preceeding an A statement is not referenced by a DO statement The transforms employed by the scanner are given below The following legend is used text fragment boundaries non terminal syntactic tokens amp lab a label guaranteed to be unique with respect to those already in the containing program unit A logical IF statement is the only statement which is compound in terms of basic blocks Hence to achieve 1 above it suffices to split every logical IF statement in which the statement part is an A statement The diagram below indicates the transform used IF lt expr gt lt A statement gt IF NOT lt expr gt GO TO amp lab lt A statement gt amp lab CONTINUE The solution for 2 is difficult to motivate it as it was primarily the result of implementation issues The set of transforms employed by the BIGMAC scanner are just listed below L D Fosdick BRNANL A Fortran Program to Identify Basic Blocks in Fortran Programs Univ of Colo Tech Rpt CU CS 040 74 1974 41 Case 1 DO label is referen
Download Pdf Manuals
Related Search
Related Contents
Memup Slidepad NG 808DC 8GB Black Power Transmission Products Données sur l`efficacité des produits antimicrobiens Canon C-EXV 14 Toner Black filmadora sport fs201 Samsung Galaxy Tab S (10.5, Wi-Fi) Brugervejledning LinkLine - Speclink Manufacturers User Manual SGM_2013_10_Configuración Registro König ANT 100S-KNUK television antenna Copyright © All rights reserved.
Failed to retrieve file