Skip to content

Commit

Permalink
full support of obsolete TRANSFORM statement per Realia COBOL
Browse files Browse the repository at this point in the history
cobc/parser.y (transform_body): add full features of INSPECT CONVERTING to TRANSFORM statement, adding optional CHARACTERS
  • Loading branch information
sf-mensch committed May 15, 2022
1 parent 35bc10c commit 6e9cde8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
5 changes: 5 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2022-05-15 Simon Sobisch <[email protected]>

* parser.y (transform_body): add full features of INSPECT CONVERTING
to TRANSFORM statement, adding optional CHARACTERS

2022-05-11 Simon Sobisch <[email protected]>

* typeck.c (cb_emit_inspect): emit reduced cob_inspect_init_converting
Expand Down
11 changes: 2 additions & 9 deletions cobc/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -15648,9 +15648,9 @@ transform_statement:
;

transform_body:
display_identifier FROM simple_display_value TO simple_display_all_value
display_identifier _characters FROM inspect_from TO inspect_to
{
cb_tree x = cb_build_converting ($3, $5, cb_build_inspect_region_start ());
cb_tree x = cb_build_converting ($4, $6, cb_build_inspect_region_start ());
cb_emit_inspect ($1, x, TRANSFORM_STATEMENT);
}
;
Expand Down Expand Up @@ -17718,13 +17718,6 @@ simple_display_value:
}
;

simple_display_all_value:
simple_all_value
{
error_if_not_usage_display_or_nonnumeric_lit ($1);
}
;

inspect_from:
display_identifier_or_alphabet_name
| basic_literal
Expand Down
33 changes: 33 additions & 0 deletions tests/testsuite.src/run_misc.at
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,39 @@ AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], [])
AT_CLEANUP


AT_SETUP([TRANSFORM statement])
AT_KEYWORDS([runmisc CONVERTING ALPHABET])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
ALPHABET MY-ASCII IS STANDARD-1.
ALPHABET MY-EBCDIC IS EBCDIC.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 X PIC X(3) VALUE "BCA".
PROCEDURE DIVISION.
*> internally: "alias" to INSPECT CONVERTING
TRANSFORM X FROM "ABC" TO "BCD".
IF X NOT = "CDB"
DISPLAY "X: " X.
*> optional CHARACTERS and ALPHABETs (value test is separate)
TRANSFORM X CHARACTERS FROM MY-ASCII TO MY-EBCDIC.
*>
STOP RUN.
])

AT_CHECK([$COMPILE prog.cob], [0], [], [])
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], [])

AT_CLEANUP


AT_SETUP([INSPECT CONVERTING alphabet])
AT_KEYWORDS([runmisc ASCII EBCDIC])

Expand Down

0 comments on commit 6e9cde8

Please sign in to comment.