From 555bc343fc79ec0588543dcb1e7fec3ce9674990 Mon Sep 17 00:00:00 2001 From: tsh-hashimoto Date: Thu, 7 Nov 2024 09:31:53 +0900 Subject: [PATCH 1/3] Update to throw CobolStopRunException --- cobj/codegen.c | 2 +- .../jp/osscons/opensourcecobol/libcobj/common/GetInt.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cobj/codegen.c b/cobj/codegen.c index 615ea2ed..2d233a0f 100644 --- a/cobj/codegen.c +++ b/cobj/codegen.c @@ -1973,7 +1973,7 @@ static void joutput_cond(cb_tree x, int save_flag) { } joutput_indent("(new GetInt() {"); joutput_indent_level += 2; - joutput_indent("public int run(){"); + joutput_indent("public int run() throws CobolStopRunException {"); joutput_indent_level += 2; for (; x; x = CB_CHAIN(x)) { // 最後の文ならreturn文を書く diff --git a/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java b/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java index cacc233e..de5468ba 100644 --- a/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java +++ b/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java @@ -18,6 +18,8 @@ */ package jp.osscons.opensourcecobol.libcobj.common; +import jp.osscons.opensourcecobol.libcobj.exceptions.CobolStopRunException; + /** TODO: 準備中 */ public interface GetInt { /** @@ -25,5 +27,5 @@ public interface GetInt { * * @return TODO: 準備中 */ - int run(); + int run() throws CobolStopRunException; } From d97b94061bdf2cfd229d00c76efab9bc9c4ed7d9 Mon Sep 17 00:00:00 2001 From: tsh-hashimoto Date: Thu, 7 Nov 2024 00:44:22 +0000 Subject: [PATCH 2/3] Update javadoc to GetInt.java --- cobj/pplex.c | 6 +++--- .../jp/osscons/opensourcecobol/libcobj/common/GetInt.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cobj/pplex.c b/cobj/pplex.c index 3be62fbb..bffa4e5a 100644 --- a/cobj/pplex.c +++ b/cobj/pplex.c @@ -379,7 +379,7 @@ typedef unsigned int flex_uint32_t; * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define YY_START (((yy_start)-1) / 2) +#define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) @@ -2632,8 +2632,8 @@ YY_DECL { default: YY_FATAL_ERROR("fatal flex scanner internal error--no action found"); } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ + } /* end of scanning one token */ + } /* end of user's declarations */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer diff --git a/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java b/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java index de5468ba..3dd2ffcb 100644 --- a/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java +++ b/libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java @@ -26,6 +26,7 @@ public interface GetInt { * TODO: 準備中 * * @return TODO: 準備中 + * @throws CobolStopRunException TODO: 準備中 */ int run() throws CobolStopRunException; } From 46496c06aff11168e5ff4b3cd9d93486a75ddd27 Mon Sep 17 00:00:00 2001 From: tsh-hashimoto Date: Thu, 7 Nov 2024 01:34:27 +0000 Subject: [PATCH 3/3] Add a new test --- cobj/pplex.c | 6 +++--- tests/Makefile.am | 3 ++- tests/Makefile.in | 3 ++- tests/misc.at | 1 + tests/misc.src/perform-until-div.at | 25 +++++++++++++++++++++++++ 5 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 tests/misc.src/perform-until-div.at diff --git a/cobj/pplex.c b/cobj/pplex.c index bffa4e5a..3be62fbb 100644 --- a/cobj/pplex.c +++ b/cobj/pplex.c @@ -379,7 +379,7 @@ typedef unsigned int flex_uint32_t; * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define YY_START (((yy_start) - 1) / 2) +#define YY_START (((yy_start)-1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) @@ -2632,8 +2632,8 @@ YY_DECL { default: YY_FATAL_ERROR("fatal flex scanner internal error--no action found"); } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ + } /* end of scanning one token */ + } /* end of user's declarations */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer diff --git a/tests/Makefile.am b/tests/Makefile.am index 9841b799..d12e5eb5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -220,7 +220,8 @@ misc_DEPENDENCIES = \ misc.src/japanese-char-section-var.at \ misc.src/evaluate-switch.at \ misc.src/fserial-variable.at \ - misc.src/file-handler-japanese.at + misc.src/file-handler-japanese.at \ + misc.src/perform-until-div.at EXTRA_DIST = $(srcdir)/package.m4 \ $(TESTS) \ diff --git a/tests/Makefile.in b/tests/Makefile.in index dad91307..64a8f7bc 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -759,7 +759,8 @@ misc_DEPENDENCIES = \ misc.src/japanese-char-section-var.at \ misc.src/evaluate-switch.at \ misc.src/fserial-variable.at \ - misc.src/file-handler-japanese.at + misc.src/file-handler-japanese.at \ + misc.src/perform-until-div.at EXTRA_DIST = $(srcdir)/package.m4 \ $(TESTS) \ diff --git a/tests/misc.at b/tests/misc.at index 7f8a6157..449c5271 100644 --- a/tests/misc.at +++ b/tests/misc.at @@ -50,3 +50,4 @@ m4_include([japanese-char-section-var.at]) m4_include([evaluate-switch.at]) m4_include([fserial-variable.at]) m4_include([file-handler-japanese.at]) +m4_include([perform-until-div.at]) diff --git a/tests/misc.src/perform-until-div.at b/tests/misc.src/perform-until-div.at new file mode 100644 index 00000000..db986153 --- /dev/null +++ b/tests/misc.src/perform-until-div.at @@ -0,0 +1,25 @@ +AT_SETUP([PERFORM UNTIL whose condition contains division]) + +AT_DATA([prog.cbl], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 CNT PIC 9(4) VALUE 1000. + 01 I PIC 9(4) VALUE 1. + PROCEDURE DIVISION. + MAIN. + PERFORM + VARYING I + FROM 1 BY 1 + UNTIL I > (CNT + 743) / 744 + PERFORM SUB + END-PERFORM + STOP RUN. + SUB. + DISPLAY "HELLO". +]) + +AT_CHECK([${COBJ} prog.cbl]) + +AT_CLEANUP