If you’re following Software Evolution at UTwente, you are implementing BabyCobol in phases called “levels”. This page sorts features of BabyCobol into those levels.
All the videos can be found in the playlist on YouTube.
LEVEL 1 LEVEL 2 LEVEL 3 LEVEL 4 LEVEL 5 LEVEL 6ACCEPT
ADD
DISPLAY
WITH NO ADVANCING clause is mandatoryDELIMITED BY clause is not requiredDIVIDE
EVALUATE
IF
END can be made mandatory at this pointMOVE
MULTIPLY
PERFORM
TIMES clause is necessary to supportTHROUGH clauses is not requiredSTOP
SUBTRACT
PICTUREs, comment lines, identification division clause valuesif, void, etc) are reserved, which means they cannot be used as variable namesA, B, C, D, E and F are declared fields, so are ADD and TO, the following are correct parses with keywords in bold:ADD A TO B ADD C TO D ADD E TO F. (three statements, no ambiguity)ADD A to B ADD C TO D ADD E TO F. (two statements, lowercase potential keyword resolves to a part of an identifier)ADD A TO B ADD C to D ADD E TO F. (two statements, same reason)ADD A TO B ADD C TO D ADD E to F. (three statements, the last lowercase potential keyword does not lead to ambiguity)ADD A to B ADD C to D ADD E TO F. (one statement, two lowercase potential keywords resolve to identifier parts)ADD A to B ADD C TO D ADD E to F. (two statements, the last lowercase potential keyword does not lead to ambiguity)ADD A TO B ADD C to D ADD E to F.
ADD A TO B ADD C to D ADD E to F. (one "fix": the last lowercase potential keyword upgraded to a keyword)ADD A TO B ADD C to D ADD E to F. (also one fix because upgrading the first lowercase potential keyword leaves no choices for the last one)ADD A to B ADD C to D ADD E to F.
ADD A to B ADD C to D ADD E to F. (the last lowercase potential keyword upgraded to a keyword)ADD A to B ADD C to D ADD E to F. (the second lowercase potential keyword upgraded to a keyword; the third one auto-coevolves)ADD A to B ADD C to D ADD E to F. (the first one and the last one are upgraded, if this was the only alternative we could have potentially resolved it claiming that this is two fixes and the other path takes one)ADD A to B ADD C to D ADD E to F. (also two fixes: the first and the second lowercase potential keywords get upgraded, the third one coevolves)ACCOUNTNUMBER, ACCOUNT-NUMBER, ACCOUNT and NUMBER are all defined fields:IF ACCOUNT-NUMBER = 0 THEN STOP. (uses the ACCOUNT-NUMBER field)IF ACCOUNT - NUMBER = 0 THEN STOP. (uses the difference between fields called ACCOUNT and NUMBER)MOVE 42 TO ACCOUNTNUMBER. (assigns the value to the ACCOUNTNUMBER field)MOVE 42 TO ACCOUNT NUMBER. (assigns the value to both fields ACCOUNT and NUMBER)MOVE 42 TO ACCOUNT NUM BER. (invalid since whitespace information is not clear enough to disambiguate)DATA DIVISION
IDENTIFICATION DIVISION contents is trivialPROCEDURE DIVISION comes down to parsing statements implemented at level 1.OF
MOVE 42 TO A OF B OF C.OFs from the top to the leaf) and only data types number(9) and number(X).OCCURS clauses
LIKE clauses
NEXT SENTENCE NEXT SENTENCE should take the computation to the beginning of the next sentence, and cleanly exit any IFs and LOOPs that stand in the wayNEXT SENTENCE from the last sentence of a paragraph, in which case the execution continues in the next paragraph or terminates the program if there are no more statements to executeLOOP
VARYING clause present without sufficient information from other clause, makes use of default rangesWHILE clause) depends on the place they are usedIF, EVALUATE and WHEN, can be contracted, for example:
IF X = 10 OR X = 20 THEN … can be written as IF X = 10 OR 20 THEN … IF X > 10 AND X < 20 THEN … can be written as IF X > 10 AND < 20 THEN …IF X > 10 AND X < 20 OR X < 100 AND X > 80 THEN … can be written as IF X > 10 AND < 20 OR 100 AND > 80 THEN …CALL
PROCEDURE DIVISION also needs its USING clause implemented.COPY
REPLACING clause.GO TO
GO TO statement of BabyCobol, with the statically resolvable paragraph name as the argument.GO TO terminates all currently executing LOOP statementsGO TO terminates the currently executing PERFORM THROUGH directive if its target is outside of the executing scope
PERFORM THROUGH
THROUGH clause to the PERFORM statement implemented at Level 1LIKE clauses01 A. 03 B. 05 C. 07 D PICTURE IS 999. 05 E. 07 D PICTURE IS 999. 07 F PICTURE IS 999.D is illegal since it is insufficientD OF B and D OF A are also illegal because neither is insufficientD OF C OF B OF A and D OF E OF B OF A are valid references to fields with full qualificationD OF C is sufficient to refer to D OF C OF B OF AD OF C OF B is sufficient to refer to D OF C OF B OF AD OF C OF A is sufficient to refer to D OF C OF B OF AD OF E is sufficient to refer to D OF E OF B OF AD OF E OF B is sufficient to refer to D OF E OF B OF AD OF E OF A is sufficient to refer to D OF E OF B OF A01 G LIKE C. — which would define a new top-level record named G having the same structure as sufficiently qualified C OF B OF A.PICTURE clause PICTURE clauses in BabyCobol's DATA DIVISIONACCEPT and DISPLAY statementsMOVE and other statements must not break the picture-consistency of valuesMOVE should be extended to cover three figurative constants as a value being assigned:
SPACES: moving it to a field gives it its default value (0 for a 9-position, space for A/X/Z/S, and dot for V)HIGH-VALUES: moving it to a field gives it its highest possible value (9 for a 9/Z-position, small z for A, character #255 for X, plus for S, dot for V)LOW-VALUES: moving it to a field gives it its lowest possible value (0 for a 9-position, space for A/Z, character #0 for X, minus for S, dot for V)MOVE SPACES TO A B C can mean three very different assignmentsMOVE
MOVE E TO C and MOVE C TO E will only reassign the field D and will never change the value of FMOVE E TO B will cause no assignments.ADD, MOVE and SUBTRACT should work on composite data structures now a-la COBOL's CORRESPONDINGGO TO
GO TO <label>" from level 4.GO TO <field>".GO TO, and the actual control flow depends on the runtime value of this named field.ALTER
GO TO Y, then it is possible to alter the target of that statement to Z, by writing ALTER X TO PROCEED TO Z.SIGNAL
SIGNAL OFF ON ERROR
OFF, the statement above is ambiguous and should result in a compilation error.