Skip to content

Commit be50acf

Browse files
committed
fix: allow whenever in data division
1 parent f992409 commit be50acf

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

server/engine/src/main/antlr4/org/eclipse/lsp/cobol/core/parser/Db2SqlParser.g4

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ procedureDivisionRules: ((dbs_allocate | dbs_alter | dbs_associate | dbs_call |
2424
dbs_label | dbs_lock | dbs_merge | dbs_open | dbs_prepare | dbs_refresh | dbs_release | dbs_rename |
2525
dbs_revoke | dbs_rollback | dbs_savepoint | dbs_select | dbs_set | dbs_signal | dbs_transfer | dbs_truncate |
2626
dbs_update | dbs_values | dbs_whenever) dbs_semicolon_end?)+ EOF;
27-
rulesAllowedInDataDivision: ((dbs_declare_cursor | dbs_declare_table | dbs_include) dbs_semicolon_end?)+;
27+
rulesAllowedInDataDivision: ((dbs_declare_cursor | dbs_whenever | dbs_declare_table | dbs_include) dbs_semicolon_end?)+;
2828
rulesAllowedInWorkingStorageAndLinkageSection: ((dbs_begin | dbs_end | dbs_include_sqlca | dbs_include_sqlda) dbs_semicolon_end?)+;
2929

3030
//used in working-storage section of cobol program

server/engine/src/test/java/org/eclipse/lsp/cobol/usecases/sql/TestSqlExecInDataSection.java

+12
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
* Test EXEC SQL in data definition section
2424
*/
2525
class TestSqlExecInDataSection {
26+
private static final String TEXT_WHENEVER = " IDENTIFICATION DIVISION.\n"
27+
+ " PROGRAM-ID. WE.\n"
28+
+ " ENVIRONMENT DIVISION.\n"
29+
+ " DATA DIVISION.\n"
30+
+ " WORKING-STORAGE SECTION.\n"
31+
+ " EXEC SQL \n"
32+
+ " WHENEVER SQLERROR GO TO 1000-ABEND-RTN \n" // FIXME 1000-ABEND-RTN should cause an error
33+
+ " END-EXEC.";
2634
private static final String TEXT = " IDENTIFICATION DIVISION.\n"
2735
+ " PROGRAM-ID. SQLISSUE.\n"
2836
+ " ENVIRONMENT DIVISION.\n"
@@ -41,4 +49,8 @@ class TestSqlExecInDataSection {
4149
void test() {
4250
UseCaseEngine.runTest(TEXT, ImmutableList.of(), ImmutableMap.of());
4351
}
52+
@Test
53+
void testWhenever() {
54+
UseCaseEngine.runTest(TEXT_WHENEVER, ImmutableList.of(), ImmutableMap.of());
55+
}
4456
}

0 commit comments

Comments
 (0)