Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/21/ibmsim.sim
There is 1 other file named ibmsim.sim in the archive. Click here to see a list.
OPTIONS(/W/-Q/-A/-I/-D);
COMMENT --- IBMSIM program Version 2.1 ---
Date:	74-12-09, 75-09-04, 76-02-27, 78-06-16
----------------------------------------------------------------------
Author: Mats Ohlin
Swedish Research Institute of National Defence
FOA 1
Fack
S-104 50 STOCKHOLM 80
SWEDEN

The information in this document is subject to change without
notice. The institute assumes no responsibility for any errors that
may be present in this document. The described software is furnished
to the user for use on a SIMULA system. (SIMULA is a registered
trademark of the Norwegian Computing Center, Oslo, Norway).

Copyright 1975 by the Swedish Research Institute for National Defence.
Copying is allowed.
----------------------------------------------------------------------

The IBMSIM program converts SIMULA programs from IBM 360/370
to DEC System-10 representation.

The following conversion problems must be considered by the
programmer:-

1. The use of standard procedures RANK and CHAR gives different
   result on DEC 10 compared with most other systems.
2. The file names must be no longer than six characters (the 7th and 8th
   characters will be ignored if present).
3. The maximal number of subscripts is 10 in DEC 10 but 127 in IBM SIMULA.
4. Virtual quantities may only be LABEL, SWITCH or (type) PROCEDURE
   in DEC 10 SIMULA. This problem could often be solved with the help of
   type procedures.
5. Subscript checking in DEC 10, unlike IBM, is made for every index element.
6. The EXTERNAL declarations must be changed.
7. Some of the mathematical standard procedures do not have double precision
   in DEC 10 SIMULA (the compiler will warn you if necessary).

See also SIMULA Language Handbook, Part 2, Chapter 4.

The IBMSIM program makes the following conversions:-

1. Changing the source input control cards (records) -
   %(NO)SOURCE,%PAGE,%TITLE to their DEC 10 SIMULA OPTIONS
   equivalents.
2. Eliminating control records %(NO)LIST and %INDENT=n.
   In order to indent your program, use the SIMED program afterwards.
3. Warns for numerical constants out of range (ABS(10log(abs(x))) > 37).
4. Eliminates card seqeunce numbers, if present.
5. Converts LONG REAL constants to DEC 10 SIMULA format.

The user is asked for the following information:-

1.	The file name for the program file, which must have a record length
	not exceeding 80.
2.	The name of the output file (if no name is given a spooled LPT
	file is generated).
3.	The input representation of the NOT symbol, output as \.

	[End of IBMSIM.HLP]
;
BEGIN    EXTERNAL TEXT PROCEDURE rest,upcase,conc2,tsub;
    EXTERNAL LONG REAL PROCEDURE scanreal;
    EXTERNAL INTEGER PROCEDURE scanint,checkint;
    EXTERNAL CLASS safmin;

safmin BEGIN
    CHARACTER ctab,cnot;   text t;
    REF (Infile) prog;	REF (Outfile) outf;
    TEXT progname,outname;   INTEGER begincount,endcount;

    PROCEDURE warning(message,t);   NAME message;   TEXT message,t;
    BEGIN
        Outtext("Warning *** ");   Outtext(message);
        IF t.Length > Length THEN
        BEGIN  WHILE t.More DO Outchar(t.Getchar)  END ELSE
        Outtext(t);
        Outtext(" ***");   Outimage
    END OF WARNING;

    BOOLEAN PROCEDURE help1;
    BEGIN
	Outtext("Enter the file description for the file you want converted.");
	Outimage
    END OF HELP1;

    BOOLEAN PROCEDURE help2;
    BEGIN
	Outtext("Enter the file description for the resulting file.");
	Outimage
    END OF HELP2;

    BOOLEAN PROCEDURE help3;
    BEGIN    outline("Enter the character representation for the NOT symbol as");
	outline("achivied by your card reader/tape conversion program.");
	outline("Very often this will be the character '^'.");
    END OF HELP3;

    Outtext("IBMSIM - SIMULA Conversion Program. Version 1.1");
    Outimage;
    request("Enter program file name",nodefault,textinput(progname,
    TRUE),"? Illegal file spec.",help1);
    prog:- NEW Infile(conc2("INPUT ",progname));

    request("Enter output file name","LPT:",textinput(outname,outname =/= NOTEXT),
    "? Illegal file spec.",help2);
    outf:- NEW Outfile(conc2("IBMSIM ",outname));

    request("Enter input representation of NOT symbol","^",textinput(t,NOT(
    t.Length NE 1 OR Digit(t.Sub(1,1).Getchar) OR Letter(t.Sub(1,1).Getchar))),
    "? Please answer with just one character.",help3);
    cnot:= t.Getchar;
    ctab:= Char(9);

    INSPECT outf DO
    BEGIN   Open(Blanks(135));

        INSPECT prog DO
        BEGIN
            PROCEDURE getstring;
            BEGIN
                t:- t.Main;   t:= NOTEXT;   t.Setpos(1);
                t.Putchar(window);   go to l;

                WHILE (IF Letter(c) THEN TRUE ELSE IF Digit(c) THEN TRUE ELSE
                IF c = '_' THEN TRUE ELSE IF c = '$' THEN TRUE ELSE
                IF c = '#' THEN TRUE ELSE c = '@') DO
                BEGIN   t.Putchar(c);  l:   IF \ More THEN go to ready;
                c:= Inchar   END;

                Setpos(Pos-1);
                ready:	t:- t.Sub(1,t.Pos-1)
            END OF GETSTRING;

            PROCEDURE nextimage;
            BEGIN
		IF textflag THEN
		BEGIN   Image:- mainimage;
		    FOR p:= 72 STEP -1 UNTIL 2 DO
		    BEGIN   c:= Image.Sub(p,1).Getchar;
			IF c NE ' ' AND c NE '"' THEN
			BEGIN   Outtext(Image.Sub(1,p-1));   Outimage;
			    Image:- Image.Sub(p,Length-p+1);
			    GO TO (IF Image.Strip == NOTEXT THEN skip ELSE print);
			END;
		    END;
		END textflag;
		print:
		Outtext(Image);   Outimage;
		skip:
                Image:- mainimage;
                Inimage;
                Image:- Image.Sub(1,72).Strip;
                WHILE Image == NOTEXT DO
                BEGIN   Outimage;
                    Image:- mainimage;   Inimage;
                    Image:- Image.Sub(1,72).Strip
                END
            END OF NEXTIMAGE;

            CHARACTER window,c;   TEXT mainimage;
            BOOLEAN endcommentflag,commentflag,textflag;
            INTEGER i,p;

            t:- Blanks(140);
            Open(Blanks(80));   mainimage:- Image;   nextimage;


            WHILE \ Endfile DO
            BEGIN   next:

                IF NOT More THEN nextimage;

                IF endcommentflag THEN go to scanendcomment;
                IF textflag THEN go to scantext;
                IF commentflag THEN go to scancomment;

                window:= Inchar;

                scan:
                IF window = ' ' OR window = ctab OR window = ';' THEN !SKIP IT;
                ELSE
		IF window = cnot THEN Image.Sub(Pos-1,1).Putchar('\') ELSE
                IF (IF Letter(window) THEN TRUE ELSE IF window = '_' THEN TRUE
                ELSE
                IF window = '$' THEN TRUE ELSE IF window = '#' THEN TRUE ELSE
                window = '@') THEN
                BEGIN   p:= Pos -1;   getstring;
                    IF t = "COMMENT" THEN go to scancomment;
                    IF t = "OPTIONS" THEN go to scancomment;
		    IF t = "END" THEN
                    BEGIN
                        moreends:
                        endcount:= endcount + 1;
                        IF endcount > begincount THEN
                        warning("More ENDs than BEGINs at line:",Image);
                        scanendcomment:
                        WHILE More DO
                        BEGIN   window:= Inchar;
                            IF window = 'E' THEN
                            BEGIN   p:= Pos - 1;   getstring;
                                IF t = "END" THEN   go to moreends;
                                IF t = "ELSE" THEN
                                BEGIN
                                    endcommentflag:= FALSE;    go to next
                                END;
                            END ELSE
                            IF window = 'O' THEN
                            BEGIN   p:= Pos - 1;   getstring;
                                IF t = "OTHERWISE" THEN
                                BEGIN
                                    endcommentflag:= FALSE;   go to next
                                END;
                            END ELSE
                            IF window = 'W' THEN
                            BEGIN   p:= Pos - 1;   getstring;
                                IF t = "WHEN" THEN
                                BEGIN   endcommentflag:= FALSE;
                                go to next   END
                            END ELSE
                            IF window = ';' THEN
                            BEGIN   endcommentflag:= FALSE;    go to next END
                        END  MORE LOOP;
                        endcommentflag:= TRUE;
                    END *ND=T ELSE
                    IF (IF window = 'B' THEN t = "BEGIN" ELSE FALSE) THEN
                    begincount:= begincount + 1;

                END ONE OR MORE LETTERS ELSE
                IF window = '"' THEN
                BEGIN	 scantext:
                    window:= ' ';
                    WHILE (IF More THEN window \= '"' ELSE FALSE) DO
                    window:= Inchar;

                    IF window \= '"' THEN
                    BEGIN
                        warning("<CR><LF> in text constant:",Image);
                        textflag:= TRUE
                    END
                    ELSE textflag:= FALSE;

                END ELSE
		IF window = '%' AND Pos = 2 THEN
		BEGIN   window:= Inchar;
		    IF tsub(Image,2,4) = "PAGE" THEN Outtext("OPTIONS(/P);") ELSE
		    IF tsub(Image,2,5) = "TITLE" THEN
		    BEGIN
			Outtext("OPTIONS(/P:""");
			Outtext(Image.Sub(10,Length-9).Strip);
			Outtext(""");");   Outimage;
		    END ELSE
		    IF tsub(Image,2,6) = "SOURCE" THEN Outtext("OPTIONS(/L);") ELSE
		    IF tsub(Image,2,7)= "NORESWD" THEN !skip; ELSE
		    IF tsub(Image,2,8) = "NOSOURCE" THEN Outtext("OPTIONS(/-L);");
		    Image:= NOTEXT;   Setpos(0);
		END ELSE
		IF Digit(window) OR (IF window = '.' AND  More THEN
		Digit(Image.Sub(Pos,1).Getchar) ELSE FALSE) THEN
		BEGIN
		    p:= IF Digit(window) THEN -2 ELSE -1;
		    WHILE More AND (Digit(window) OR window = ctab OR
		    window = '.' OR window = ' ') DO
		    BEGIN   IF window = '.' THEN p:= Abs(p) ELSE
			IF Digit(window) THEN p:= p + Sign(p);
			window:= Inchar
		    END;
		    i:= Pos;
		    IF window = '&' AND More THEN
		    BEGIN
			IF p > 9 THEN BEGIN
			Image:- conc2(conc2(Image.Sub(1,Pos-1),"&"),
			Image.Sub(Pos,Length-Pos+1));   Setpos(i+1);
			END;
			amp:
			i:= Pos;
			IF checkint(Image) = 1 THEN
			BEGIN   Setpos(i);   i:= Inint;
			    IF Abs(i) > 37 THEN warning("Numerical constant out of range:",Image);
			END ELSE Setpos(i);
		    END ELSE
		    IF p > 9 THEN
		    BEGIN    Image:- conc2(conc2(Image.Sub(1,Pos-2),"&&0 "),
			Image.Sub(Pos-1,Length-Pos+2));   Setpos(i+2)
		    END;
		END ELSE
		IF window = '&' THEN GO TO amp ELSE
                IF window = ''' THEN
                BEGIN
                    IF \ More THEN
                    w0: warning("Character constant at line:",Image) ELSE
                    BEGIN   Setpos(Pos+1);
                        IF \ More THEN go to w0;
                        window:= Inchar;
                        IF window \= ''' THEN go to w0
                    END
                END ELSE
                IF window = '!' THEN
                BEGIN
		    scancomment:   textflag:= FALSE;
		    WHILE (IF More THEN window \= ';' OR
		    (IF t = "OPTIONS" THEN textflag ELSE FALSE) ELSE FALSE) DO
		    BEGIN   window:= Inchar;
			textflag:= NOT (window = '"' EQV textflag)
		    END;
		    textflag:= FALSE;   t:= NOTEXT;
                    commentflag:= window \= ';';
                END;
            END BIG LOOP;

            Close
        END INSPECTING INPUT;
        Close
    END INSPECTING OUTPUT;
    Outtext("Processing ready.");   Outimage;
    Outtext("Number of BEGIN (END) found:");   Outint(begincount,5);
    IF endcount \= begincount THEN
    BEGIN   Outtext("  (");   Outint(endcount,5);   Outchar(')');
	Outtext(" ******************")
    END;
    Outimage
END prefixed block
END OF PROGRAM