grammarware / software-evolution

Software Evolution
MIT License
1 stars 0 forks source link

String literals without quotes #22

Open eefscheef opened 4 months ago

eefscheef commented 4 months ago

Currently we are revisiting the DISPLAY statement. We allow the DISPLAY statement to take string literals without quote strings, but this goes south if this literal could also be a keyword.

1) What should happen when executing the following program?

IDENTIFICATION DIVISION .
  PROGRAM-ID. FIB.
PROCEDURE DIVISION .
DISPLAY GIVING. 

2) Do we even need to support string literals without quotes outside of identifier names?

grammarware commented 4 months ago

"String literals without quotes" is a very strange way to say "identifiers", but yes, they exist in BabyCobol, and thus need to be supported.

Any identifier which is not defined explicitly in the DATA DIVISION, has an initial value of its own name in uppercase, so your program will print GIVING. You can reassign it a different value, and then it will hold it instead (cropped at length 6 because its default type would then be PICTURE X(6). So this:

IDENTIFICATION DIVISION .
  PROGRAM-ID. FIB.
PROCEDURE DIVISION .
MOVE "IDENTIFICATION" TO GIVING.
DISPLAY GIVING. 

will only print IDENTI.