The Implementation Of A Special Language Interpreter

(A Thesis Presented to The Faculty of the Department of Applied Science The College of William and Mary in Virginia - August 1975)
by James Thomas Lee, Jr. 07/05/97

APPENDIX A

THE MAT STATEMENT IN USE

In Section IIB, para lb, the Interpreter deals with the Input/Output Instructions, both formatted and unformatted. The illustration presented here should indicate the advantage in the MAT Statement. In Figures 9 and 10, the user will observe the same problem in four different output situations.

In Figure 9, the output is handled using the MAT Statement. In the listing, the solution is obviously easier to read because the numbers are not sloppily printed with leading and trailing zeroes. The printout of the real array has some extra zeroes; however, they are there by request from the MAT instruction in line 87. The MAT Statement has ordered four real numbers to be printed, each with field length seven including two digits to the right of the decimal.

In Figure 10, the printouts are not organized by the MAT Statement, so the format designed by the Interpreter, as the default case, must be used. The user will note how unorderly these listings are, particularly in the real array case. Without a doubt, the MAT Statements enable clearer and easier to read output.

---------------------------------------------------------------------------------------------------------------------------

Figure 9. Below are two cases in which the MAT Statement has been used. The first case is printing an integer matrix, and the second case prints the same array but as a real matrix.

---------------------------------------------------------------------------------------------------------------------------

Case 1).  Printing of a formatted integer array

	02	03	04	05
	03	04	05	06
	04	05	06	07
	05	06	07	08

ADDRESS REQUEST	00052520
ADDRESS		PROGRAM LISTING			REGISTERS	COUNTERS
0000000		INTEGER A(4,4),I,J		A  00000001	PROG		00120
0000014		FOR I=1TO 4			Q  00006325	COUNT		00001
0000025		FOR J=l TO 4			Bl 00000241	STMTPTR		00009
0000036		A(I,J)=I+J			B2 00000061	POINTER		00012
0000047		BACK				B3 00000000	DATAPTR		00015
0000051		WRITE 1,A(I,I),A(I,2),A(I,3),A(1,4)
0000084		1:MAT (5X,I2,5X,I2,5X,I2,5X,I2)
0000112		BACK
0000116		TERMINATE

NORMAL TERMINATION OF PROGRAM
_____________________________________________________________________________

Case 2).    Printing of a formatted real array

	0002.00		0003.00		0004.00		0005.00
	0003.00		0004.00		0005.00		0006.00
	0004.00		0005.00		0006.00		0007.00
	0005.00		0006.00		0007.00		0008.00

ADDRESS  REQUEST	00052520
ADDRESS    	PROGRAM LISTING			REGISTERS	COUNTERS
0000000		REAL A(4,4)			A  00000001	PROG		00131
0000010		INTEGER I,J			Q  00006325	COUNT		00001
0000011		FOR I=1 TO 4			B1 00000262	STMTPTR		00010
0000028		FOR J=l TO 4			B2 00000142	POINTER		00012
0000039		A(I,J)=I+J			B3 00000000	DATAPTR		00030
0000050		BACK
0000054		WRITE I)A(I,l),A(I,2),A(I,3),A(I,4)
0000087		1:MAT (5X,F7.2,5X,F7.2,5X,F7.2,5X,F7.2)
0000123		BACK
0000127		TERMINATE

NORMAL TERMINATION OF   PROGRAM

---------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------

Figure 10. Below are two cases using the same matrix as in Figure 9, only in these examples, the MAT Statement has not been used. In the first case, the integer array is printed; in the second case, the real array is printed.

---------------------------------------------------------------------------------------------------------------------------

Case 1).  Printing of an unformatted integer array

	0000002		0000003		0000004		0000005
	0000003		0000004		0000005		0000006
	0000004		0000005		0000006		0000007
	0000005		0000006		0000007		0000008

ADDRESS  REQUEST	00052520
ADDRESS    	PROGRAM LISTING			REGISTERS	COUNTERS
0000000		INTEGER A(4,4),I,J		A  00000001	PROG		00090
0000014		FOR I=l TO 4			Q  00006325	COUNT		0000l
0000025		FOR J=l TO 4			Bl 00000156	STMTPTR		00008
0000036		A(I,J)=I+J			B2 00000061	POINTER		00009
0000047		BACK				B3 00000034	DATAPTR		00015
0000051		WRITE A(I,I),A(I,2),A(I,3),A(I,4)
0000082		BACK
0000086		TERMINATE

NORMAL TERMINATION OF PROGRAM
_____________________________________________________________________________

Case 2).    Printing of an unformatted real array

0000002.0000000   0000003.0000000   0000004.0000000   0000005.0000000
0000003.0000000   0000004.0000000   0000005.0000000   0000006.0000000
0000004.0000000   0000005.0000000   0000006.0000000   0000007.0000000
0000005.0000000   0000006.0000000   0000007.0000000   0000008.0000000

ADDRESS  REQUEST	00052520
ADDRESS    	PROGRAM LISTING			REGISTERS	COUNTERS
0000000		REAL A(4,4)			A  00000001	PROG		00093
0000010		INTEGER I, J			Q  00006325	COUNT		00001
0000017		FOR I=l TO 4			Bl 00000161	STMTPTR		00009
0000028		FOR J=l TO 4			B2 00000142	POINTER		00009
0000039		A(I,J)=I+J			B3 00000034	DATAPTR		00030
0060050		BACK
0000054		WRITE A(I,l),A(I,2),A(I,3),A(I,4)
0000085		BACK
0000089		TERMINATE

NORMAL TERMINATION OF PROGRAM

---------------------------------------------------------------------------------------------------------------------------



APPENDIX B

FUNCTION ACCURACY

A very significant factor for the Interpreter is just how well are the functions being calculated. It is definitely important to have an efficient technique to calculate these values; however, if the values are inaccurate, the user will be in trouble. Therefore, first emphasis is given to accuracy and second concern to technique.

In the figures which follow, Figures 11 and 12, the reader will observe a series of function evaluations. The calculated values are printed to the seventh decimal and have been verified to be accurate to the seventh decimal by a calculator. By being able to insure calculator accuracy for most calculations, the Interpreter passes the accuracy test. Although the example programs only evaluate the EXP, LN, SIN,.COS, and SQRT functions, each function of the Interpreter has undergone independent testing with the same high results; thus, the Interpreter has licked the problem of providing dependable solutions. Now, the concern can turn to more efficient operation.

---------------------------------------------------------------------------------------------------------------------------

Figure 11. Below is a sample program which demonstrates the preciseness of the Interpreter's functions.

---------------------------------------------------------------------------------------------------------------------------

	1.01005	  0.00000   0.17364   0.98480   03.1622776   03.1622776
	1.02020	  0.69314   0.34202   0.93969   04.4721359   04.4721359
	1.03045	  1.09861   0.49999   0.86602   05.4772255	 05.4772255
	1.04081	  1.38629   0.64278   0.76604   06.3245553   06.3245553
	1.05127   1.60943   0.76604   0.64278   07.0710678   07.0710678
	1.06183	  1.79175   0.86602   0.50000   07.7459666   07.7459666
	1.07250	  1.94591   0.93969   0.34202   08.3666002   08.3666002
	1.08328	  2.07944   0.98480   0.17364   08.9442719   08.9442719
	1.09417   2.19722   1.00000   0.00000   09.4868329   09.4868329
	1.10517   2.30258   0.98480  -0.17364   10.0000000   10.0000000

ADDRESS  REQUEST	00052520
ADDRESS    	PROGRAM LISTING			REGISTERS	COUNTERS
0000000		REAL A(6)			A  00000001	PROG		00225
0000008		INTEGER I			Q  00006325	COUNT		00001
0000013		I=1 				BI 00000161	STMTPTR		00015
0000017		WHILE (I.LE.10) 		B2 00000242	POINTER		00006
0000030		A(1)=EXP (I/100) 		B3 00000000	DATAPTR		00013
0000046		A(2)=LN(I)
0000058		A(3)=SIN(I*10)
0000073		A(4)=COS(I*10)
0000088		A(5)=SQRT(I*10)
0000103		A(6)=(I*10)**(1/2)
0000122		WRITE 1,A(l),A(2),A(3),A(4),A(5),A(6)
0000157		I=I+l
0000163		BACK
0000167		1:MAT'(F7.5,2X,F7.5,lX,F7.15,2X,F7.5,2X,F10.7,2XFlO.-7)
0000221		TERMINATE

NORMAL TERMINATION OF PROGRAM

---------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------

Figure 12. Below is another example which demonstrates the accuracy of the squareroot function.

---------------------------------------------------------------------------------------------------------------------------


		1000.00000	31.6227766	31.6227766
		0989.26786	31.4526288	31.4526288
		0978.53572	31.2815555	31.2815555
		0967.80358	31.1095416	31.1095416
		0957.07144	30.9365712	30.9365712
		0946.33930	30.7626283	30.7626283
		0935.60716	30.5876962	30.5876962
		0924.87502	30.4117579	30.4117579
		0914.14288	30.2347958	30.2347958
		0903.41074	30.0567919	30.0567919

ADDRESS  REQUEST	00052520
ADDRESS    	PROGRAM LISTING			REGISTERS	COUNTERS
0000000		REAL A,B,I			A  00000001	PROG		00115
0000009		I=1000				Q  00006325	COUNT		00001
0000016		WHILE (I.GT.900)		Bl 00000126	STMTPTR		00010
0000030		A=SQRT(I)			B2 00000162	POINTER		00009
0000039		B=I**(1/2)			B3 00000000	DATAPTR		00006
0000050		WRITE 1,I,A,B
0000061		1:MAT (5X,F10.5,5X,FlO.7,5X,F10.7)
0000094		I=I-10.73214
0000107		BACK
0000111		TERMINATE

NORMAL TERMINATION OF PROGRAM

---------------------------------------------------------------------------------------------------------------------------



APPENDIX C

LOGICAL EXPRESSIONS

In addition to performing normal arithmetic calculations, the Interpreter also provides the capability to evaluate Boolean expressions. A Boolean expression in its most simple form is the assignment to a Boolean variable the value of TRUE or FALSE. As the expression becomes more complex, the value is arrived at by comparing two subexpressions, x and y, where the level of comparison is set by a logical operator. For a discussion of logical operators, see Section IIB, para la3. The most sophisticated level of Boolean expression is achieved by combining the above subexpressions with another set of subexpressions by a logical conjunction. These conjunctions were discussed in Section IIB, para 2b. For an illustration of these types of Boolean expressions in use, see Figure 13.

---------------------------------------------------------------------------------------------------------------------------

Figure 13. Below is a sample program demonstrating the use of Boolean expressions.

---------------------------------------------------------------------------------------------------------------------------


					TRUE
					FALSE
					FALSE
					TRUE
					TRUE
					TRUE
					TRUE
					FALSE

ADDRESS  REQUEST	00052520
ADDRESS    	PROGRAM LISTING			REGISTERS	COUNTERS
0000000		BOOLEAN A,B,C			A  00000001	PROG		00186
0000009		A="T"				Q  00006325	COUNT		00001
0000015		WRITE A				Bl 00000271	STMTPTR		00018
0000020		B="F"				B2 00000000	POINTER		00009
0000026		WRITE B				B3 00000000	DATAPTR		00002
0000031		C=B
0000035		WRITE C
0000040		C= (A.EQ."T")
0000053		WRITE C
0000058		C= (A.EQ."T") AND (B.NE."T'l)
0000084		WRITE C
0000089		C= (A.EQ."T") OR (B.EQ."T")
0000115		WRITE C
0000120		C= (A.EQ."F") OR (B.EQ."F")
0000146		WRITE C
0000151		C= (A.EQ."T") OR (B.EQ."F")
0000177		WRITE C
0000182		TERMINATE

NORMAL TERMINATION OF PROGRAM

---------------------------------------------------------------------------------------------------------------------------

BIBLIOGRAPHY

Back To The Table Of Contents

Back To TLEE's Home Page

Send email to: tlee6040@aol.com