1 |
720 |
jeremybenn |
-- MACROSUB.ADA
|
2 |
|
|
--
|
3 |
|
|
-- Grant of Unlimited Rights
|
4 |
|
|
--
|
5 |
|
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
6 |
|
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
7 |
|
|
-- unlimited rights in the software and documentation contained herein.
|
8 |
|
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
9 |
|
|
-- this public release, the Government intends to confer upon all
|
10 |
|
|
-- recipients unlimited rights equal to those held by the Government.
|
11 |
|
|
-- These rights include rights to use, duplicate, release or disclose the
|
12 |
|
|
-- released technical data and computer software in whole or in part, in
|
13 |
|
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
14 |
|
|
-- to do so.
|
15 |
|
|
--
|
16 |
|
|
-- DISCLAIMER
|
17 |
|
|
--
|
18 |
|
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
19 |
|
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
20 |
|
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
21 |
|
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
22 |
|
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
23 |
|
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
24 |
|
|
--*
|
25 |
|
|
--
|
26 |
|
|
-----------------------------------------------------------------------
|
27 |
|
|
-- --
|
28 |
|
|
-- THIS PROGRAM IS CALLED MACROSUB. IT IS USED TO REPLACE THE --
|
29 |
|
|
-- MACROS IN THE ACVC TEST SUITE WITH THEIR PROPER VALUES. THE --
|
30 |
|
|
-- STEPS LISTED BELOW SHOULD BE FOLLOWED TO ENSURE PROPER RUNNING --
|
31 |
|
|
-- OF THE MACROSUB PROGRAM: --
|
32 |
|
|
-- --
|
33 |
|
|
-- 1) Edit the file MACRO.DFS (included with the testtape) --
|
34 |
|
|
-- and insert your macro values. The macros which use --
|
35 |
|
|
-- the value of MAX_IN_LEN are calculated automatically --
|
36 |
|
|
-- and do not need to be entered. --
|
37 |
|
|
-- --
|
38 |
|
|
-- 2) Create a file called TSTTESTS.DAT which includes all --
|
39 |
|
|
-- of the .TST test file names and their directory --
|
40 |
|
|
-- specifications, if necessary. If a different name --
|
41 |
|
|
-- other than TSTTESTS.DAT is used, this name must be --
|
42 |
|
|
-- substituted in the MACROSUB.ADA file. --
|
43 |
|
|
-- --
|
44 |
|
|
-- 3) Compile and link MACROSUB. --
|
45 |
|
|
-- --
|
46 |
|
|
-- 4) Run the MACROSUB program. --
|
47 |
|
|
-- --
|
48 |
|
|
-- WHEN THE PROGRAM FINISHES RUNNING, THE MACROS WILL HAVE BEEN --
|
49 |
|
|
-- REPLACED WITH THE APPROPRIATE VALUES FROM MACRO.DFS. --
|
50 |
|
|
-- --
|
51 |
|
|
-- --
|
52 |
|
|
-- --
|
53 |
|
|
-- HISTORY: --
|
54 |
|
|
-- BCB 04/17/90 CHANGED MODE OF CALC_MAX_VALS TO OUT. CHANGED --
|
55 |
|
|
-- VALUE OF MAX_VAL_LENGTH FROM 512 TO 400. ADDED --
|
56 |
|
|
-- EXCEPTION HANDLER SO PROGRAM DOES NOT CRASH IF --
|
57 |
|
|
-- AN EXCEPTION IS RAISED. ADDED MESSAGES TO --
|
58 |
|
|
-- REPORT PROGRESS OF PROGRAM. CHANGED PROGRAM SO --
|
59 |
|
|
-- IT DOES NOT ABORT IF A FILE CANNOT BE FOUND. --
|
60 |
|
|
-- MODIFIED PROGRAM SO IT ACCEPTS FILENAMES WITH --
|
61 |
|
|
-- VERSION NUMBERS. --
|
62 |
|
|
-----------------------------------------------------------------------
|
63 |
|
|
|
64 |
|
|
WITH TEXT_IO;
|
65 |
|
|
USE TEXT_IO;
|
66 |
|
|
|
67 |
|
|
PACKAGE DEFS IS
|
68 |
|
|
|
69 |
|
|
-----------------------------------------------------------------------
|
70 |
|
|
-- --
|
71 |
|
|
-- THIS PACKAGE IS USED BY MACROSUB.ADA, PARSEMAC.ADA, AND BY --
|
72 |
|
|
-- GETSUBS.ADA. THE PACKAGE CONTAINS VARIABLE DECLARATIONS WHICH --
|
73 |
|
|
-- NEED TO BE KNOWN BY ALL OF THE PROCEDURES AND PACKAGES WHICH --
|
74 |
|
|
-- MAKE UP THE PROGRAM. --
|
75 |
|
|
-- --
|
76 |
|
|
-----------------------------------------------------------------------
|
77 |
|
|
|
78 |
|
|
MAX_VAL_LENGTH : CONSTANT INTEGER := 400;
|
79 |
|
|
|
80 |
|
|
SUBTYPE VAL_STRING IS STRING (1..MAX_VAL_LENGTH);
|
81 |
|
|
|
82 |
|
|
TYPE REC_TYPE IS RECORD
|
83 |
|
|
MACRO_NAME : STRING (1..80);
|
84 |
|
|
NAME_LENGTH, VALUE_LENGTH : INTEGER;
|
85 |
|
|
MACRO_VALUE : VAL_STRING;
|
86 |
|
|
END RECORD;
|
87 |
|
|
|
88 |
|
|
TYPE TABLE_TYPE IS ARRAY (1..100) OF REC_TYPE;
|
89 |
|
|
|
90 |
|
|
SYMBOL_TABLE : TABLE_TYPE;
|
91 |
|
|
|
92 |
|
|
NUM_MACROS : INTEGER;
|
93 |
|
|
|
94 |
|
|
END DEFS;
|
95 |
|
|
|
96 |
|
|
WITH TEXT_IO;
|
97 |
|
|
USE TEXT_IO;
|
98 |
|
|
WITH DEFS;
|
99 |
|
|
USE DEFS;
|
100 |
|
|
|
101 |
|
|
PACKAGE GETSUBS IS
|
102 |
|
|
|
103 |
|
|
------------------------------------------------------------------------
|
104 |
|
|
-- --
|
105 |
|
|
-- THIS PACKAGE IS USED BY MACROSUB.ADA FOR READING FROM MACRO.DFS --
|
106 |
|
|
-- THE VALUES FOR THE MACRO SUBSTITUTIONS FOR A TEST TAPE. --
|
107 |
|
|
-- --
|
108 |
|
|
------------------------------------------------------------------------
|
109 |
|
|
|
110 |
|
|
MAC_FILE, LINE_LEN : EXCEPTION;
|
111 |
|
|
|
112 |
|
|
PROCEDURE CALC_MAX_VALS(INDEX, LENGTH, MAX_IN_LEN : IN INTEGER;
|
113 |
|
|
CALCULATED : OUT BOOLEAN);
|
114 |
|
|
|
115 |
|
|
PROCEDURE FILL_TABLE;
|
116 |
|
|
|
117 |
|
|
END GETSUBS;
|
118 |
|
|
|
119 |
|
|
PACKAGE BODY GETSUBS IS
|
120 |
|
|
|
121 |
|
|
-----------------------------------------------------------------------
|
122 |
|
|
-- --
|
123 |
|
|
-- PROCEDURE CALC_MAX_VALS CALCULATES THE VALUE FOR THE MACRO --
|
124 |
|
|
-- READ FROM MACRO.DFS IF ITS LENGTH IS EQUAL OR NEARLY EQUAL TO --
|
125 |
|
|
-- MAX_IN_LEN. IT THEN RETURNS A FLAG SET TO TRUE IF A VALUE WAS --
|
126 |
|
|
-- CALCULATED, FALSE IF ONE WAS NOT. --
|
127 |
|
|
-- --
|
128 |
|
|
-----------------------------------------------------------------------
|
129 |
|
|
|
130 |
|
|
PROCEDURE CALC_MAX_VALS(INDEX, LENGTH, MAX_IN_LEN : IN INTEGER;
|
131 |
|
|
CALCULATED : OUT BOOLEAN) IS
|
132 |
|
|
|
133 |
|
|
BEGIN
|
134 |
|
|
|
135 |
|
|
IF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) = "BIG_ID1"
|
136 |
|
|
THEN SYMBOL_TABLE (INDEX).MACRO_VALUE (1..MAX_IN_LEN) :=
|
137 |
|
|
(1..(MAX_IN_LEN-1) => 'A') & "1";
|
138 |
|
|
CALCULATED := TRUE;
|
139 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
140 |
|
|
"BIG_ID2" THEN SYMBOL_TABLE (INDEX).MACRO_VALUE
|
141 |
|
|
(1..MAX_IN_LEN) := (1..(MAX_IN_LEN-1) => 'A') & "2";
|
142 |
|
|
CALCULATED := TRUE;
|
143 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
144 |
|
|
"BIG_ID3" THEN SYMBOL_TABLE (INDEX).MACRO_VALUE
|
145 |
|
|
(1..MAX_IN_LEN) := (1..(MAX_IN_LEN + 1)/2 => 'A') & "3" &
|
146 |
|
|
((MAX_IN_LEN + 1)/2 + 2..MAX_IN_LEN => 'A');
|
147 |
|
|
CALCULATED := TRUE;
|
148 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
149 |
|
|
"BIG_ID4" THEN SYMBOL_TABLE (INDEX).MACRO_VALUE
|
150 |
|
|
(1..MAX_IN_LEN) := (1..(MAX_IN_LEN + 1)/2 => 'A') & "4" &
|
151 |
|
|
((MAX_IN_LEN + 1)/2 + 2..MAX_IN_LEN => 'A');
|
152 |
|
|
CALCULATED := TRUE;
|
153 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
154 |
|
|
"BIG_STRING1" THEN SYMBOL_TABLE (INDEX).MACRO_VALUE
|
155 |
|
|
(1..(MAX_IN_LEN + 1)/2 + 2) :=
|
156 |
|
|
'"' & (1..(MAX_IN_LEN + 1)/2 => 'A') & '"';
|
157 |
|
|
CALCULATED := TRUE;
|
158 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
159 |
|
|
"BIG_STRING2" THEN SYMBOL_TABLE (INDEX).MACRO_VALUE
|
160 |
|
|
(1..MAX_IN_LEN - (MAX_IN_LEN + 1)/2 + 2) :=
|
161 |
|
|
'"' & (2..MAX_IN_LEN - (MAX_IN_LEN + 1)/2 => 'A') &
|
162 |
|
|
'1' & '"';
|
163 |
|
|
CALCULATED := TRUE;
|
164 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
165 |
|
|
"MAX_STRING_LITERAL" THEN SYMBOL_TABLE (INDEX).
|
166 |
|
|
MACRO_VALUE (1..MAX_IN_LEN) := '"' &
|
167 |
|
|
(1..MAX_IN_LEN-2 => 'A') & '"';
|
168 |
|
|
CALCULATED := TRUE;
|
169 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
170 |
|
|
"BIG_INT_LIT" THEN SYMBOL_TABLE (INDEX).MACRO_VALUE
|
171 |
|
|
(1..MAX_IN_LEN) := (1..MAX_IN_LEN-3 => '0') & "298";
|
172 |
|
|
CALCULATED := TRUE;
|
173 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
174 |
|
|
"BIG_REAL_LIT" THEN SYMBOL_TABLE (INDEX).MACRO_VALUE
|
175 |
|
|
(1..MAX_IN_LEN) := (1..MAX_IN_LEN-5 => '0') & "690.0";
|
176 |
|
|
CALCULATED := TRUE;
|
177 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
178 |
|
|
"MAX_LEN_INT_BASED_LITERAL" THEN
|
179 |
|
|
SYMBOL_TABLE (INDEX).
|
180 |
|
|
MACRO_VALUE (1..MAX_IN_LEN) := "2:" &
|
181 |
|
|
(1..MAX_IN_LEN - 5 => '0') & "11:";
|
182 |
|
|
CALCULATED := TRUE;
|
183 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
184 |
|
|
"MAX_LEN_REAL_BASED_LITERAL" THEN SYMBOL_TABLE (INDEX).
|
185 |
|
|
MACRO_VALUE (1..MAX_IN_LEN) := "16:" &
|
186 |
|
|
(1..MAX_IN_LEN - 7 => '0') & "F.E:";
|
187 |
|
|
CALCULATED := TRUE;
|
188 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
189 |
|
|
"BLANKS" THEN SYMBOL_TABLE (INDEX).MACRO_VALUE
|
190 |
|
|
(1..MAX_IN_LEN-20) := (1..MAX_IN_LEN-20 => ' ');
|
191 |
|
|
CALCULATED := TRUE;
|
192 |
|
|
ELSE
|
193 |
|
|
CALCULATED := FALSE;
|
194 |
|
|
END IF;
|
195 |
|
|
IF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
196 |
|
|
"BLANKS" THEN SYMBOL_TABLE (INDEX).VALUE_LENGTH :=
|
197 |
|
|
MAX_IN_LEN - 20;
|
198 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
199 |
|
|
"BIG_STRING1" THEN
|
200 |
|
|
SYMBOL_TABLE (INDEX).VALUE_LENGTH :=
|
201 |
|
|
(MAX_IN_LEN + 1)/2 + 2;
|
202 |
|
|
ELSIF SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) =
|
203 |
|
|
"BIG_STRING2" THEN
|
204 |
|
|
SYMBOL_TABLE (INDEX).VALUE_LENGTH :=
|
205 |
|
|
MAX_IN_LEN - (MAX_IN_LEN + 1)/2 + 2;
|
206 |
|
|
ELSE SYMBOL_TABLE (INDEX).VALUE_LENGTH := MAX_IN_LEN;
|
207 |
|
|
END IF;
|
208 |
|
|
END CALC_MAX_VALS;
|
209 |
|
|
|
210 |
|
|
-----------------------------------------------------------------------
|
211 |
|
|
-- --
|
212 |
|
|
-- PROCEDURE FILL_TABLE READS THE MACRO NAMES AND MACRO VALUES IN --
|
213 |
|
|
-- FROM MACRO.DFS AND STORES THEM IN THE SYMBOL TABLE. PROCEDURE --
|
214 |
|
|
-- CALC_MAX_VALS IS CALLED TO DETERMINE IF THE MACRO VALUE SHOULD --
|
215 |
|
|
-- BE CALCULATED OR READ FROM MACRO.DFS. --
|
216 |
|
|
-- --
|
217 |
|
|
-----------------------------------------------------------------------
|
218 |
|
|
|
219 |
|
|
PROCEDURE FILL_TABLE IS
|
220 |
|
|
|
221 |
|
|
INFILE1 : FILE_TYPE;
|
222 |
|
|
MACRO_FILE : CONSTANT STRING := "MACRO.DFS";
|
223 |
|
|
A_LINE : VAL_STRING;
|
224 |
|
|
I, INDEX, LENGTH, HOLD, A_LENGTH, NAME : INTEGER;
|
225 |
|
|
MAX_IN_LEN : INTEGER := 1;
|
226 |
|
|
CALCULATED : BOOLEAN;
|
227 |
|
|
|
228 |
|
|
BEGIN
|
229 |
|
|
INDEX := 1;
|
230 |
|
|
BEGIN
|
231 |
|
|
OPEN (INFILE1, IN_FILE, MACRO_FILE);
|
232 |
|
|
EXCEPTION
|
233 |
|
|
WHEN NAME_ERROR =>
|
234 |
|
|
PUT_LINE ("** ERROR: MACRO FILE " & MACRO_FILE &
|
235 |
|
|
" NOT FOUND.");
|
236 |
|
|
RAISE MAC_FILE;
|
237 |
|
|
END;
|
238 |
|
|
WHILE NOT END_OF_FILE (INFILE1) LOOP
|
239 |
|
|
GET_LINE (INFILE1, A_LINE, A_LENGTH);
|
240 |
|
|
IF A_LENGTH > 0 AND A_LINE (1..2) /= "--" AND
|
241 |
|
|
A_LINE (1) /= ' ' AND A_LINE (1) /= ASCII.HT THEN
|
242 |
|
|
I := 1;
|
243 |
|
|
WHILE I <= A_LENGTH AND THEN
|
244 |
|
|
((A_LINE (I) IN 'A'..'Z') OR
|
245 |
|
|
(A_LINE (I) IN '0'..'9') OR
|
246 |
|
|
A_LINE (I) = '_') LOOP
|
247 |
|
|
I := I + 1;
|
248 |
|
|
END LOOP;
|
249 |
|
|
I := I - 1;
|
250 |
|
|
LENGTH := I;
|
251 |
|
|
BEGIN
|
252 |
|
|
SYMBOL_TABLE (INDEX).MACRO_NAME (1..LENGTH) :=
|
253 |
|
|
A_LINE (1..I);
|
254 |
|
|
EXCEPTION
|
255 |
|
|
WHEN CONSTRAINT_ERROR =>
|
256 |
|
|
PUT_LINE ("** ERROR: LINE LENGTH IS " &
|
257 |
|
|
"GREATER THAN MAX_VAL_LENGTH.");
|
258 |
|
|
RAISE LINE_LEN;
|
259 |
|
|
END;
|
260 |
|
|
SYMBOL_TABLE (INDEX).NAME_LENGTH := I;
|
261 |
|
|
CALC_MAX_VALS (INDEX, LENGTH, MAX_IN_LEN,
|
262 |
|
|
CALCULATED);
|
263 |
|
|
IF NOT CALCULATED THEN
|
264 |
|
|
I := I + 1;
|
265 |
|
|
WHILE A_LINE (I) = ' ' OR A_LINE (I) =
|
266 |
|
|
ASCII.HT LOOP
|
267 |
|
|
I := I + 1;
|
268 |
|
|
IF SYMBOL_TABLE (INDEX).MACRO_NAME
|
269 |
|
|
(1..LENGTH) = "BLANKS" THEN
|
270 |
|
|
EXIT;
|
271 |
|
|
END IF;
|
272 |
|
|
END LOOP;
|
273 |
|
|
HOLD := I;
|
274 |
|
|
|
275 |
|
|
-- MACRO VALUE BEGINS AT POSITION HOLD.
|
276 |
|
|
-- NOW FIND WHERE IT ENDS BY STARTING AT THE END OF THE INPUT
|
277 |
|
|
-- LINE AND SEARCHING BACKWARD FOR A NON-BLANK.
|
278 |
|
|
|
279 |
|
|
I := A_LENGTH;
|
280 |
|
|
WHILE I > HOLD AND THEN (A_LINE (I) = ' '
|
281 |
|
|
OR A_LINE(I) = ASCII.HT) LOOP
|
282 |
|
|
I := I - 1;
|
283 |
|
|
END LOOP;
|
284 |
|
|
LENGTH := I - HOLD + 1;
|
285 |
|
|
SYMBOL_TABLE (INDEX).MACRO_VALUE (1..LENGTH)
|
286 |
|
|
:= A_LINE (HOLD..I);
|
287 |
|
|
SYMBOL_TABLE (INDEX).VALUE_LENGTH := LENGTH;
|
288 |
|
|
NAME := SYMBOL_TABLE (INDEX).NAME_LENGTH;
|
289 |
|
|
IF SYMBOL_TABLE (INDEX).MACRO_NAME (1..NAME) =
|
290 |
|
|
"MAX_IN_LEN" THEN MAX_IN_LEN :=
|
291 |
|
|
INTEGER'VALUE (SYMBOL_TABLE (INDEX).
|
292 |
|
|
MACRO_VALUE (1..LENGTH));
|
293 |
|
|
END IF;
|
294 |
|
|
END IF;
|
295 |
|
|
INDEX := INDEX + 1;
|
296 |
|
|
END IF;
|
297 |
|
|
END LOOP;
|
298 |
|
|
NUM_MACROS := INDEX - 1;
|
299 |
|
|
CLOSE (INFILE1);
|
300 |
|
|
END FILL_TABLE;
|
301 |
|
|
|
302 |
|
|
BEGIN
|
303 |
|
|
NULL;
|
304 |
|
|
END GETSUBS;
|
305 |
|
|
|
306 |
|
|
WITH TEXT_IO;
|
307 |
|
|
USE TEXT_IO;
|
308 |
|
|
WITH DEFS;
|
309 |
|
|
USE DEFS;
|
310 |
|
|
|
311 |
|
|
PACKAGE PARSEMAC IS
|
312 |
|
|
|
313 |
|
|
------------------------------------------------------------------------
|
314 |
|
|
-- --
|
315 |
|
|
-- THIS PACKAGE IS USED BY MACROSUB.ADA FOR FINDING A MACRO TO --
|
316 |
|
|
-- SUBSTITUTE. MACRO SUBSTITUTIONS ARE MADE IN *.TST TESTS IN THE --
|
317 |
|
|
-- ACVC TEST SUITE. THIS PROCEDURE IS CURRENTLY SET UP FOR ACVC --
|
318 |
|
|
-- VERSION 1.10. --
|
319 |
|
|
-- --
|
320 |
|
|
------------------------------------------------------------------------
|
321 |
|
|
|
322 |
|
|
PROCEDURE LOOK_FOR_MACRO (A_LINE : IN STRING;
|
323 |
|
|
A_LENGTH : IN INTEGER;
|
324 |
|
|
PTR : IN OUT INTEGER;
|
325 |
|
|
MACRO : OUT STRING;
|
326 |
|
|
MACRO_LEN : IN OUT INTEGER);
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
PROCEDURE WHICH_MACRO (MACRO : IN STRING;
|
330 |
|
|
MACRO_LEN : IN INTEGER;
|
331 |
|
|
TEMP_MACRO : OUT STRING;
|
332 |
|
|
TEMP_MACRO_LEN : IN OUT INTEGER);
|
333 |
|
|
|
334 |
|
|
END PARSEMAC;
|
335 |
|
|
|
336 |
|
|
PACKAGE BODY PARSEMAC IS
|
337 |
|
|
|
338 |
|
|
-----------------------------------------------------------------------
|
339 |
|
|
-- PROCEDURE LOOK_FOR_MACRO LOOKS FOR A DOLLAR SIGN WHICH SIGNALS --
|
340 |
|
|
-- THE START OF A MACRO IN THE *.TST FILES. IT THEN COUNTS --
|
341 |
|
|
-- CHARACTERS UNTIL A <LETTER>, <NUMBER>, OR <_> IS NOT FOUND. --
|
342 |
|
|
-- RETURN PARAMETERS SEND THE BEGINNING POINTER AND LENGTH OF THE --
|
343 |
|
|
-- MACRO BACK TO THE MAIN PROGRAM. ALSO RETURNED IS THE MACRO --
|
344 |
|
|
-- STRING. --
|
345 |
|
|
-----------------------------------------------------------------------
|
346 |
|
|
|
347 |
|
|
PROCEDURE LOOK_FOR_MACRO (A_LINE : IN STRING;
|
348 |
|
|
A_LENGTH : IN INTEGER;
|
349 |
|
|
PTR : IN OUT INTEGER;
|
350 |
|
|
MACRO : OUT STRING;
|
351 |
|
|
MACRO_LEN : IN OUT INTEGER) IS
|
352 |
|
|
|
353 |
|
|
II, J : INTEGER := INTEGER'LAST;
|
354 |
|
|
|
355 |
|
|
BEGIN
|
356 |
|
|
FOR I IN PTR..A_LENGTH LOOP
|
357 |
|
|
IF A_LINE (I) = '$' THEN
|
358 |
|
|
II := I+1;
|
359 |
|
|
EXIT;
|
360 |
|
|
END IF;
|
361 |
|
|
II := I;
|
362 |
|
|
END LOOP;
|
363 |
|
|
IF II < A_LENGTH THEN -- DOLLAR SIGN IS FOUND.
|
364 |
|
|
J := II;
|
365 |
|
|
WHILE J <= A_LENGTH AND THEN ((A_LINE(J) IN 'A'..'Z') OR
|
366 |
|
|
(A_LINE(J) IN '0'..'9') OR
|
367 |
|
|
A_LINE(J) = '_') LOOP
|
368 |
|
|
J := J+1;
|
369 |
|
|
END LOOP;
|
370 |
|
|
J := J-1;
|
371 |
|
|
MACRO_LEN := (J-II+1);
|
372 |
|
|
MACRO (1..MACRO_LEN) := A_LINE (II .. J);
|
373 |
|
|
-- DON'T INCLUDE THE DOLLAR SIGN
|
374 |
|
|
PTR := J+1;
|
375 |
|
|
ELSE
|
376 |
|
|
MACRO_LEN := 0;
|
377 |
|
|
END IF;
|
378 |
|
|
RETURN;
|
379 |
|
|
END LOOK_FOR_MACRO;
|
380 |
|
|
|
381 |
|
|
------------------------------------------------------------------------
|
382 |
|
|
-- PROCEDURE WHICH_MACRO COMPARES THE INPUT MACRO STRING TO A --
|
383 |
|
|
-- VALUE READ FROM MACRO.DFS AND STORED IN THE SYMBOL TABLE AND --
|
384 |
|
|
-- RETURNS THE MACRO SUBSTITUTION STRING BACK TO THE MAIN PROGRAM. --
|
385 |
|
|
------------------------------------------------------------------------
|
386 |
|
|
|
387 |
|
|
PROCEDURE WHICH_MACRO (MACRO : IN STRING;
|
388 |
|
|
MACRO_LEN : IN INTEGER;
|
389 |
|
|
TEMP_MACRO : OUT STRING;
|
390 |
|
|
TEMP_MACRO_LEN : IN OUT INTEGER) IS
|
391 |
|
|
|
392 |
|
|
BEGIN
|
393 |
|
|
FOR INDEX IN 1 .. NUM_MACROS LOOP
|
394 |
|
|
IF MACRO (1..MACRO_LEN) =
|
395 |
|
|
SYMBOL_TABLE (INDEX).MACRO_NAME
|
396 |
|
|
(1..SYMBOL_TABLE (INDEX).NAME_LENGTH) THEN
|
397 |
|
|
TEMP_MACRO_LEN :=
|
398 |
|
|
SYMBOL_TABLE (INDEX).VALUE_LENGTH;
|
399 |
|
|
TEMP_MACRO (1..TEMP_MACRO_LEN) :=
|
400 |
|
|
SYMBOL_TABLE (INDEX).MACRO_VALUE
|
401 |
|
|
(1..TEMP_MACRO_LEN);
|
402 |
|
|
EXIT;
|
403 |
|
|
END IF;
|
404 |
|
|
IF INDEX = NUM_MACROS THEN
|
405 |
|
|
PUT_LINE ("** ERROR: MACRO " & MACRO (1..MACRO_LEN)
|
406 |
|
|
& " NOT FOUND. UPDATE PROGRAM.");
|
407 |
|
|
TEMP_MACRO_LEN := MACRO_LEN;
|
408 |
|
|
TEMP_MACRO (1..TEMP_MACRO_LEN) :=
|
409 |
|
|
MACRO (1..MACRO_LEN);
|
410 |
|
|
END IF;
|
411 |
|
|
END LOOP;
|
412 |
|
|
|
413 |
|
|
END WHICH_MACRO;
|
414 |
|
|
|
415 |
|
|
BEGIN
|
416 |
|
|
NULL;
|
417 |
|
|
END PARSEMAC;
|
418 |
|
|
|
419 |
|
|
WITH TEXT_IO, GETSUBS, PARSEMAC, DEFS;
|
420 |
|
|
USE TEXT_IO, GETSUBS, PARSEMAC, DEFS;
|
421 |
|
|
|
422 |
|
|
PROCEDURE MACROSUB IS
|
423 |
|
|
|
424 |
|
|
------------------------------------------------------------------------
|
425 |
|
|
-- --
|
426 |
|
|
-- MACROSUB IS THE MAIN PROGRAM THAT CALLS PROCEDURES IN TWO --
|
427 |
|
|
-- PACKAGES, GETSUBS AND PARSEMAC. THIS PROGRAM IS USED TO MAKE --
|
428 |
|
|
-- THE MACRO SUBSTITUTIONS FOR TST TESTS IN THE ACVC TEST SUITE. --
|
429 |
|
|
-- --
|
430 |
|
|
------------------------------------------------------------------------
|
431 |
|
|
|
432 |
|
|
INFILE1, INFILE2, OUTFILE1 : FILE_TYPE;
|
433 |
|
|
FNAME, MACRO : VAL_STRING;
|
434 |
|
|
LENGTH, A_LENGTH, PTR,
|
435 |
|
|
TEMP_MACRO_LENGTH, MACRO_LEN, FILE_COUNT : INTEGER := 0;
|
436 |
|
|
A_LINE, TEMP_MACRO, TEMP_LINE, NEW_LINE : VAL_STRING;
|
437 |
|
|
END_OF_LINE_SEARCH, FLAG : BOOLEAN := FALSE;
|
438 |
|
|
TESTS_FILE : CONSTANT STRING := "TSTTESTS.DAT";
|
439 |
|
|
TSTTESTS,FILE_CRE : EXCEPTION;
|
440 |
|
|
|
441 |
|
|
BEGIN
|
442 |
|
|
PUT_LINE ("BEGINNING MACRO SUBSTITUTIONS.");
|
443 |
|
|
FILL_TABLE;
|
444 |
|
|
BEGIN
|
445 |
|
|
OPEN (INFILE2, IN_FILE, TESTS_FILE);
|
446 |
|
|
EXCEPTION
|
447 |
|
|
WHEN NAME_ERROR =>
|
448 |
|
|
PUT_LINE ("** ERROR: ERROR DURING OPENING OF " &
|
449 |
|
|
"TSTTESTS.DAT");
|
450 |
|
|
RAISE TSTTESTS;
|
451 |
|
|
END;
|
452 |
|
|
WHILE NOT END_OF_FILE (INFILE2) LOOP
|
453 |
|
|
GET_LINE (INFILE2, FNAME, LENGTH);
|
454 |
|
|
FILE_COUNT := FILE_COUNT + 1;
|
455 |
|
|
BEGIN
|
456 |
|
|
OPEN (INFILE1, IN_FILE, FNAME(1..LENGTH));
|
457 |
|
|
EXCEPTION
|
458 |
|
|
WHEN NAME_ERROR =>
|
459 |
|
|
PUT_LINE ("** ERROR: ERROR DURING OPENING OF " &
|
460 |
|
|
FNAME(1..LENGTH) & ".");
|
461 |
|
|
FLAG := TRUE;
|
462 |
|
|
END;
|
463 |
|
|
IF NOT FLAG THEN
|
464 |
|
|
PUT_LINE ("WORKING ON " & FNAME(1..LENGTH));
|
465 |
|
|
IF FILE_COUNT = 70 THEN
|
466 |
|
|
PUT_LINE ("MACRO SUBSTITUTIONS HALF COMPLETED.");
|
467 |
|
|
END IF;
|
468 |
|
|
FOR I IN REVERSE 1 .. LENGTH LOOP
|
469 |
|
|
IF FNAME(I) = ';' THEN
|
470 |
|
|
LENGTH := I - 1;
|
471 |
|
|
EXIT;
|
472 |
|
|
END IF;
|
473 |
|
|
END LOOP;
|
474 |
|
|
IF FNAME (LENGTH-2..LENGTH) = "TST" THEN
|
475 |
|
|
FNAME (LENGTH-2..LENGTH) := "ADT";
|
476 |
|
|
ELSIF FNAME (LENGTH-2..LENGTH) = "tst" THEN
|
477 |
|
|
FNAME (LENGTH-2..LENGTH) := "adt";
|
478 |
|
|
END IF;
|
479 |
|
|
BEGIN
|
480 |
|
|
CREATE (OUTFILE1, OUT_FILE, FNAME (1..LENGTH));
|
481 |
|
|
EXCEPTION
|
482 |
|
|
WHEN OTHERS =>
|
483 |
|
|
PUT_LINE ("** ERROR: EXCEPTION RAISED DURING" &
|
484 |
|
|
" ATTEMPTED CREATION OF " &
|
485 |
|
|
FNAME(1..LENGTH) & ".");
|
486 |
|
|
RAISE FILE_CRE;
|
487 |
|
|
END;
|
488 |
|
|
WHILE NOT END_OF_FILE (INFILE1) LOOP
|
489 |
|
|
GET_LINE (INFILE1, A_LINE, A_LENGTH);
|
490 |
|
|
IF A_LENGTH > 0 AND A_LINE(1..2) /= "--" THEN
|
491 |
|
|
END_OF_LINE_SEARCH := FALSE;
|
492 |
|
|
PTR := 1;
|
493 |
|
|
WHILE NOT END_OF_LINE_SEARCH LOOP
|
494 |
|
|
LOOK_FOR_MACRO (A_LINE, A_LENGTH, PTR,
|
495 |
|
|
MACRO, MACRO_LEN);
|
496 |
|
|
IF MACRO_LEN = 0 THEN
|
497 |
|
|
END_OF_LINE_SEARCH := TRUE;
|
498 |
|
|
ELSE -- SEE WHICH MACRO IT IS
|
499 |
|
|
WHICH_MACRO (MACRO, MACRO_LEN,
|
500 |
|
|
TEMP_MACRO, TEMP_MACRO_LENGTH);
|
501 |
|
|
END IF;
|
502 |
|
|
IF NOT END_OF_LINE_SEARCH THEN
|
503 |
|
|
IF PTR-MACRO_LEN-2 > 0 THEN
|
504 |
|
|
-- IF MACRO IS NOT FIRST ON THE LINE
|
505 |
|
|
NEW_LINE (1..PTR-MACRO_LEN-2)
|
506 |
|
|
:= A_LINE(1..PTR-MACRO_LEN -2);
|
507 |
|
|
-- THE OLD LINE UNTIL THE DOLLAR SIGN
|
508 |
|
|
END IF;
|
509 |
|
|
NEW_LINE(PTR-MACRO_LEN-1 ..
|
510 |
|
|
TEMP_MACRO_LENGTH +
|
511 |
|
|
(PTR-MACRO_LEN) - 2) :=
|
512 |
|
|
TEMP_MACRO(1..TEMP_MACRO_LENGTH);
|
513 |
|
|
IF PTR <= A_LENGTH THEN
|
514 |
|
|
-- IF MACRO IS NOT LAST ON THE LINE
|
515 |
|
|
NEW_LINE (TEMP_MACRO_LENGTH +
|
516 |
|
|
PTR-MACRO_LEN - 1 ..
|
517 |
|
|
TEMP_MACRO_LENGTH - 1 +
|
518 |
|
|
A_LENGTH - MACRO_LEN) :=
|
519 |
|
|
A_LINE (PTR..A_LENGTH);
|
520 |
|
|
ELSE
|
521 |
|
|
END_OF_LINE_SEARCH := TRUE;
|
522 |
|
|
END IF;
|
523 |
|
|
A_LENGTH := A_LENGTH +
|
524 |
|
|
TEMP_MACRO_LENGTH -
|
525 |
|
|
MACRO_LEN - 1;
|
526 |
|
|
A_LINE (1..A_LENGTH) :=
|
527 |
|
|
NEW_LINE (1..A_LENGTH);
|
528 |
|
|
PTR := PTR - MACRO_LEN +
|
529 |
|
|
TEMP_MACRO_LENGTH - 1;
|
530 |
|
|
END IF;
|
531 |
|
|
END LOOP;
|
532 |
|
|
END IF;
|
533 |
|
|
PUT_LINE (OUTFILE1, A_LINE (1..A_LENGTH));
|
534 |
|
|
END LOOP;
|
535 |
|
|
CLOSE (OUTFILE1);
|
536 |
|
|
CLOSE (INFILE1);
|
537 |
|
|
ELSE
|
538 |
|
|
FLAG := FALSE;
|
539 |
|
|
END IF;
|
540 |
|
|
END LOOP;
|
541 |
|
|
CLOSE (INFILE2);
|
542 |
|
|
PUT_LINE ("MACRO SUBSTITUTIONS COMPLETED.");
|
543 |
|
|
EXCEPTION
|
544 |
|
|
WHEN MAC_FILE | LINE_LEN | TSTTESTS | FILE_CRE =>
|
545 |
|
|
NULL;
|
546 |
|
|
WHEN OTHERS =>
|
547 |
|
|
PUT_LINE ("UNEXPECTED EXCEPTION RAISED");
|
548 |
|
|
END MACROSUB;
|