Skip to content

Commit b8dc801

Browse files
authored
#105 add SKIP statement (#133)
close #105
1 parent 4c452f4 commit b8dc801

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

com.ca.lsp.cobol/lsp-core-cobol-parser/src/main/antlr4/com/ca/lsp/core/cobol/parser/CobolParser.g4

+2-2
Original file line numberDiff line numberDiff line change
@@ -1151,15 +1151,15 @@ paragraph
11511151
;
11521152

11531153
sentence
1154-
: statement* DOT_FS
1154+
: (statement* DOT_FS) | skipStatement+
11551155
;
11561156

11571157
statement
11581158
: acceptStatement | addStatement | alterStatement | callStatement | cancelStatement | closeStatement | computeStatement | continueStatement | deleteStatement | disableStatement |
11591159
displayStatement | divideStatement | enableStatement | entryStatement | evaluateStatement | exhibitStatement | execCicsStatement | execSqlStatement | execSqlImsStatement |
11601160
exitStatement | generateStatement | gobackStatement | goToStatement | ifStatement | initializeStatement | initiateStatement | inspectStatement | mergeStatement | moveStatement |
11611161
multiplyStatement | openStatement | performStatement | purgeStatement | readStatement | receiveStatement | releaseStatement | returnStatement | rewriteStatement | searchStatement |
1162-
sendStatement | serviceReloadStatement | serviceLabelStatement | setStatement | skipStatement | sortStatement | startStatement | stopStatement | stringStatement | subtractStatement |
1162+
sendStatement | serviceReloadStatement | serviceLabelStatement | setStatement | sortStatement | startStatement | stopStatement | stringStatement | subtractStatement |
11631163
terminateStatement | titleStatement | unstringStatement | writeStatement | xmlStatement
11641164
;
11651165

com.ca.lsp.cobol/lsp-core-cobol-parser/src/main/antlr4/com/ca/lsp/core/cobol/parser/CobolPreprocessor.g4

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ paragraphs2
7474
;
7575

7676
sentence
77-
: statement+ DOT_FS
77+
: (statement+ DOT_FS) | skipNoStatement+
7878
;
7979

8080
//all the possible combinations to form a statement, super-nongreddy
@@ -83,7 +83,7 @@ statement
8383
continueStatement | deleteStatement | disableStatement | displayStatement | divideStatement | enableStatement | entryStatement | evaluateStatement |
8484
exitStatement | generateStatement | gobackStatement | goStatement | ifStatement | initializeStatement | initiateStatement | inspectStatement | mergeStatement |
8585
multiplyStatement | openStatement | performStatement | purgeStatement | readStatement | receiveStatement | releaseStatement | returnStatement | rewriteStatement |
86-
searchStatement | sendStatement | setStatement | skipNoStatement | sortStatement | startStatement | stopStatement | stringStatement | subtractStatement | terminateStatement |
86+
searchStatement | sendStatement | setStatement | sortStatement | startStatement | stopStatement | stringStatement | subtractStatement | terminateStatement |
8787
titleStatement | unstringStatement | useStatement | writeStatement | xmlStatement |execSqlStatement | execSqlImsStatement | execCicsStatement | copyStatement
8888
;
8989

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2020 Broadcom.
3+
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
4+
*
5+
* This program and the accompanying materials are made
6+
* available under the terms of the Eclipse Public License 2.0
7+
* which is available at https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Broadcom, Inc. - initial API and implementation
13+
*/
14+
15+
package com.ca.lsp.cobol.usecases;
16+
17+
import org.junit.Test;
18+
19+
public class TestSkipStatement extends PositiveUseCase {
20+
21+
private static final String TEXT =
22+
" IDENTIFICATION DIVISION. \r\n"
23+
+ " PROGRAM-ID. SKIP_TEST.\r\n"
24+
+ " DATA DIVISION.\r\n"
25+
+ " WORKING-STORAGE SECTION. \r\n"
26+
+ " PROCEDURE DIVISION.\r\n"
27+
+ " PROGA.\r\n"
28+
+ " SKIP1\r\n"
29+
+ " PERFORM WITH TEST BEFORE UNTIL ID0 = 0\r\n"
30+
+ " SUBTRACT 1 FROM TAPARM1\r\n"
31+
+ " CALL 'ID1'\r\n"
32+
+ " END-PERFORM\r\n"
33+
+ " .\r\n"
34+
+ " SKIP2.\r\n"
35+
+ " PROGB.\r\n"
36+
+ " EXIT.\r\n"
37+
+ " EJECT";
38+
39+
public TestSkipStatement() {
40+
super(TEXT);
41+
}
42+
43+
@Test
44+
public void test() {
45+
super.test();
46+
}
47+
}

com.ca.lsp.cobol/lsp-service-cobol/src/test/java/com/ca/lsp/cobol/usecases/UseCaseSuite.java

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
@SuiteClasses({
2323
TestFormatTrim.class,
2424
TestSyntaxError.class,
25+
TestSkipStatement.class,
2526
TestVaryingCorrect.class,
2627
AnalyzeCopybookCaching.class,
2728
TestPerformUntilCorrect.class,

0 commit comments

Comments
 (0)