Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CICS Create System Command #2666

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ ATTACHSEC : A T T A C H S E C;
ATTACHTIME : A T T A C H T I M E;
ATTLS : A T T L S;
ATTRIBUTES : A T T R I B U T E S;
ATTRLEN: A T T R L E N;
AUDALARMST : A U D A L A R M S T;
AUDITLEVEL : A U D I T L E V E L;
AUDITLOG : A U D I T L O G;
Expand Down Expand Up @@ -861,6 +862,7 @@ LOSTLOCKS : L O S T L O C K S;
LOW_VALUE : L O W MINUSCHAR V A L U E;
LOW_VALUES : L O W MINUSCHAR V A L U E S;
LPASTATUS : L P A S T A T U S;
LSRPOOL: L S R P O O L;
LSRPOOLNUM : L S R P O O L N U M;
LUNAME : L U N A M E;
MAIN : M A I N;
Expand Down Expand Up @@ -1005,6 +1007,7 @@ NOINCONVERT : N O I N C O N V E R T;
NOJBUFSP : N O J B U F S P;
NOLENGTH : N O L E N G T H;
NOLINKAGE : N O L I N K A G E;
NOLOG: N O L O G;
NONE : N O N E;
NONTERMREL : N O N T E R M R E L;
NONUM : N O N U M;
Expand Down Expand Up @@ -1132,6 +1135,7 @@ PAGING : P A G I N G;
PARSE : P A R S E;
PARTCLASS : P A R T C L A S S;
PARTCOUNT : P A R T C O U N T;
PARTITIONSET: P A R T I T I O N S E T;
PARTITIONSST : P A R T I T I O N S S T;
PARTN: P A R T N;
PARTNER : P A R T N E R;
Expand Down Expand Up @@ -1453,6 +1457,7 @@ SERVSTATUS : S E R V S T A T U S;
SESSBUSY : S E S S B U S Y;
SESSION : S E S S I O N;
SESSIONERR : S E S S I O N E R R;
SESSIONS: S E S S I O N S;
SESSIONTYPE : S E S S I O N T Y P E;
SESSTOKEN : S E S S T O K E N;
SET : S E T;
Expand Down Expand Up @@ -1679,6 +1684,7 @@ TRANDUMPING : T R A N D U M P I N G;
TRANISOLATE : T R A N I S O L A T E;
TRANPRIORITY : T R A N P R I O R I T Y;
TRANSACTION : T R A N S A C T I O N;
TRANSCLASS: T R A N S C L A S S;
TRANSFORM : T R A N S F O R M;
TRANSID : T R A N S I D;
TRANSIDERR : T R A N S I D E R R;
Expand Down Expand Up @@ -1709,6 +1715,7 @@ TYPENAME : T Y P E N A M E;
TYPENAMELEN : T Y P E N A M E L E N;
TYPENS : T Y P E N S;
TYPENSLEN : T Y P E N S L E N;
TYPETERM: T Y P E T E R M;
UCTRANST : U C T R A N S T;
UDSASIZE : U D S A S I Z E;
UNATTEND : U N A T T E N D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ allExciRules: cics_exci_link | cics_exci_delete | cics_exci_delete_container | c
cics_exci_get_container | cics_exci_get_next_container | cics_exci_move_container |
cics_exci_put_container | cics_exci_query_channel | cics_exci_startbrowse_container ;

allSPRules: cics_discard | cics_inquire_system_programming;
allSPRules: cics_discard | cics_inquire_system_programming | cics_create;

// compiler options
compilerOpts
Expand Down Expand Up @@ -263,6 +263,14 @@ cics_connect_process: (PROCESS | (CONVID | SESSION | PARTNER) cics_name | PROCNA
cics_converttime: CONVERTTIME cics_converttime_opts;
cics_converttime_opts:(DATESTRING cics_data_area | ABSTIME cics_data_area | cics_handle_response)+;

/** CREATE System Commands */
cics_create: CREATE cics_create_opts;
cics_create_opts:((ATOMSERVICE | BUNDLE | DB2CONN | DB2ENTRY | DB2TRAN | DOCTEMPLATE | DUMPCODE | ENQMODEL | FILE |
IPCONN | JOURNALMODEL | JVMSERVER | LIBRARY | LSRPOOL | MAPSET | MQCONN | MQMONITOR | PARTITIONSET |
PARTNER | PIPELINE | PROCESSTYPE | PROFILE | PROGRAM | TCPIPSERVICE | TDQUEUE | TRANCLASS |
TRANSACTION | TSMODEL | TYPETERM | URIMAP | WEBSERVICE | SESSIONS | TERMINAL | CONNECTION) cics_data_value |
(ATTRIBUTES cics_data_area | COMPLETE | DISCARD | ATTRLEN cics_data_value | LOG | NOLOG | LOGMESSAGE cics_cvda | cics_handle_response))+;
KutluOzel-b marked this conversation as resolved.
Show resolved Hide resolved

/** DEFINE (all of them) */
cics_define: DEFINE (cics_define_activity | cics_define_composite_event | cics_define_counter_dcounter | cics_define_input_event | cics_define_process | cics_define_timer);
cics_define_activity: ACTIVITY cics_data_value ((EVENT | TRANSID | PROGRAM | USERID) cics_data_value | ACTIVITYID cics_data_area | cics_handle_response)+;
Expand Down Expand Up @@ -1255,6 +1263,7 @@ ABCODE
| ATTACHTIME
| ATTLS
| ATTRIBUTES
| ATTRLEN
| AUDALARMST
| AUDITLEVEL
| AUDITLOG
Expand Down Expand Up @@ -1918,6 +1927,7 @@ ABCODE
| LOW_VALUE
| LOW_VALUES
| LPASTATUS
| LSRPOOL
| LSRPOOLNUM
| LUNAME
| MAIN
Expand Down Expand Up @@ -2045,6 +2055,7 @@ ABCODE
| NOFLUSH
| NOHANDLE
| NOINCONVERT
| NOLOG
| NOJBUFSP
| NONE
| NONTERMREL
Expand Down Expand Up @@ -2157,6 +2168,7 @@ ABCODE
| PARSE
| PARTCLASS
| PARTCOUNT
| PARTITIONSET
| PARTITIONSST
| PARTN
| PARTNER
Expand Down Expand Up @@ -2458,6 +2470,7 @@ ABCODE
| SESSBUSY
| SESSION
| SESSIONERR
| SESSIONS
| SESSIONTYPE
| SESSTOKEN
| SET
Expand Down Expand Up @@ -2658,6 +2671,7 @@ ABCODE
| TRANISOLATE
| TRANPRIORITY
| TRANSACTION
| TRANSCLASS
| TRANSFORM
| TRANSID
| TRANSIDERR
Expand Down Expand Up @@ -2685,6 +2699,7 @@ ABCODE
| TYPENAMELEN
| TYPENS
| TYPENSLEN
| TYPETERM
| UCTRANST
| UDSASIZE
| UNATTEND
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright (c) 2024 Broadcom.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Broadcom, Inc. - initial API and implementation
*
*/
package org.eclipse.lsp.cobol.implicitDialects.cics.utility;

import org.antlr.v4.runtime.ParserRuleContext;

import org.eclipse.lsp.cobol.common.dialects.DialectProcessingContext;
import org.eclipse.lsp.cobol.common.error.ErrorSeverity;
import org.eclipse.lsp.cobol.common.error.SyntaxError;
import org.eclipse.lsp.cobol.implicitDialects.cics.CICSLexer;
import org.eclipse.lsp.cobol.implicitDialects.cics.CICSParser;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.eclipse.lsp.cobol.implicitDialects.cics.CICSParser.RULE_cics_create;

/** Checks CICS Create System Command rules for required and invalid options */
public class CICSCreateSPOptionsCheckUtility extends CICSOptionsCheckBaseUtility {
public static final int RULE_INDEX = RULE_cics_create;
private static final Map<Integer, ErrorSeverity> DUPLICATE_CHECK_OPTIONS =
new HashMap<Integer, ErrorSeverity>() {
{
put(CICSLexer.ATOMSERVICE, ErrorSeverity.ERROR);
put(CICSLexer.BUNDLE, ErrorSeverity.ERROR);
put(CICSLexer.DB2CONN, ErrorSeverity.ERROR);
put(CICSLexer.DB2ENTRY, ErrorSeverity.ERROR);
put(CICSLexer.DB2TRAN, ErrorSeverity.ERROR);
put(CICSLexer.DOCTEMPLATE, ErrorSeverity.ERROR);
put(CICSLexer.DUMPCODE, ErrorSeverity.ERROR);
put(CICSLexer.ENQMODEL, ErrorSeverity.ERROR);
put(CICSLexer.FILE, ErrorSeverity.ERROR);
put(CICSLexer.PIPELINE, ErrorSeverity.ERROR);
put(CICSLexer.IPCONN, ErrorSeverity.ERROR);
put(CICSLexer.JOURNALMODEL, ErrorSeverity.ERROR);
put(CICSLexer.JVMSERVER, ErrorSeverity.ERROR);
put(CICSLexer.LIBRARY, ErrorSeverity.ERROR);
put(CICSLexer.LSRPOOL, ErrorSeverity.ERROR);
put(CICSLexer.MAPSET, ErrorSeverity.ERROR);
put(CICSLexer.MQCONN, ErrorSeverity.ERROR);
put(CICSLexer.MQMONITOR, ErrorSeverity.ERROR);
put(CICSLexer.PARTITIONSET, ErrorSeverity.ERROR);
put(CICSLexer.PARTNER, ErrorSeverity.ERROR);
put(CICSLexer.PROCESSTYPE, ErrorSeverity.ERROR);
put(CICSLexer.PROFILE, ErrorSeverity.ERROR);
put(CICSLexer.PROGRAM, ErrorSeverity.ERROR);
put(CICSLexer.TCPIPSERVICE, ErrorSeverity.ERROR);
put(CICSLexer.TDQUEUE, ErrorSeverity.ERROR);
put(CICSLexer.TRANCLASS, ErrorSeverity.ERROR);
put(CICSLexer.TRANSACTION, ErrorSeverity.ERROR);
put(CICSLexer.TSMODEL, ErrorSeverity.ERROR);
put(CICSLexer.TYPETERM, ErrorSeverity.ERROR);
put(CICSLexer.URIMAP, ErrorSeverity.ERROR);
put(CICSLexer.WEBSERVICE, ErrorSeverity.ERROR);
put(CICSLexer.SESSIONS, ErrorSeverity.ERROR);
put(CICSLexer.TERMINAL, ErrorSeverity.ERROR);
put(CICSLexer.CONNECTION, ErrorSeverity.ERROR);
put(CICSLexer.ATTRIBUTES, ErrorSeverity.ERROR);
put(CICSLexer.ATTRLEN, ErrorSeverity.ERROR);
put(CICSLexer.DISCARD, ErrorSeverity.WARNING);
put(CICSLexer.COMPLETE, ErrorSeverity.WARNING);
put(CICSLexer.LOG, ErrorSeverity.WARNING);
put(CICSLexer.NOLOG, ErrorSeverity.WARNING);
put(CICSLexer.LOGMESSAGE, ErrorSeverity.ERROR);
}
};
public CICSCreateSPOptionsCheckUtility(
DialectProcessingContext context, List<SyntaxError> errors) {
super(context, errors, DUPLICATE_CHECK_OPTIONS);
}

/**
* Entrypoint to check CICS Create System Command rule options
*
* @param ctx ParserRuleContext subclass containing options
* @param <E> A subclass of ParserRuleContext
*/
public <E extends ParserRuleContext> void checkOptions(E ctx) {
if (ctx.getRuleIndex() == CICSParser.RULE_cics_create_opts)
checkOpts((CICSParser.Cics_create_optsContext) ctx);

checkDuplicates(ctx);
}
private void checkOpts(CICSParser.Cics_create_optsContext ctx) {
slavek-kucera marked this conversation as resolved.
Show resolved Hide resolved
checkHasMutuallyExclusiveOptions(ctx.ATOMSERVICE(), ctx.BUNDLE(), ctx.DB2CONN(), ctx.DB2ENTRY(), ctx.DB2TRAN(), ctx.DOCTEMPLATE(), ctx.DUMPCODE(),
slavek-kucera marked this conversation as resolved.
Show resolved Hide resolved
ctx.ENQMODEL(), ctx.FILE(), ctx.PIPELINE(), ctx.IPCONN(), ctx.JOURNALMODEL(), ctx.JVMSERVER(), ctx.LIBRARY(),
ctx.LSRPOOL(), ctx.MAPSET(), ctx.MQCONN(), ctx.MQMONITOR(), ctx.PARTITIONSET(), ctx.PARTNER(),
ctx.PROCESSTYPE(), ctx.PROFILE(), ctx.PROGRAM(), ctx.TCPIPSERVICE(), ctx.TDQUEUE(), ctx.TRANCLASS(),
ctx.TRANSACTION(), ctx.TSMODEL(), ctx.TYPETERM(), ctx.URIMAP(), ctx.WEBSERVICE(), ctx.SESSIONS(),
ctx.TERMINAL(), ctx.CONNECTION());

if (!ctx.CONNECTION().isEmpty() || !ctx.TERMINAL().isEmpty()) {
checkHasExactlyOneOption("ATTRIBUTES or COMPLETE or DISCARD", ctx, ctx.ATTRIBUTES(), ctx.COMPLETE(), ctx.DISCARD());
if (!ctx.DISCARD().isEmpty() || !ctx.COMPLETE().isEmpty()) {
checkHasIllegalOptions(ctx.ATTRLEN(), "ATTRLEN");
checkHasIllegalOptions(ctx.LOG(), "LOG");
checkHasIllegalOptions(ctx.NOLOG(), "NOLOG");
checkHasIllegalOptions(ctx.LOGMESSAGE(), "LOGMESSAGE");
}
} else {
checkHasIllegalOptions(ctx.DISCARD(), "DISCARD");
checkHasIllegalOptions(ctx.COMPLETE(), "COMPLETE");
checkHasMandatoryOptions(ctx.ATTRIBUTES(), ctx, "ATTRIBUTES");
}
checkHasMutuallyExclusiveOptions("LOG or NOLOG or LOGMESSAGE", ctx.LOG(), ctx.NOLOG(), ctx.LOGMESSAGE());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,34 @@ protected int checkHasMutuallyExclusiveOptions(String options, List<TerminalNode
}
return nodes.size();
}
/**
* Flags errors for rule lists passed as parameters if there are multiple instances of mutually
* exclusive options.
*
* @param rules Lists of TerminalNode to iterate through
* @return Number of TerminalNode instances found
*/
protected int checkHasMutuallyExclusiveOptions(List<TerminalNode>... rules) {
slavek-kucera marked this conversation as resolved.
Show resolved Hide resolved
List<TerminalNode> nodes =
Stream.of(rules)
.filter(rule -> !rule.isEmpty())
.flatMap(Collection::stream)
.collect(Collectors.toList());
nodes.removeIf(Objects::isNull);

if (!nodes.stream()
.allMatch(e -> e.getSymbol().getType() == nodes.get(0).getSymbol().getType())) {
nodes.forEach(
node -> {
throwException(
ErrorSeverity.ERROR,
getLocality(node),
"Exactly one option required, options are mutually exclusive: ",
nodes.toString().replace(",", " or").replace("[", "").replace("]", ""));
slavek-kucera marked this conversation as resolved.
Show resolved Hide resolved
});
}
return nodes.size();
}

protected <E extends ParseTree> void checkHasExactlyOneOption(
String options, ParserRuleContext parentCtx, List<E>... rules) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ public CICSOptionsCheckUtility(DialectProcessingContext context, List<SyntaxErro
spOptionsMap.put(
CICSDiscardOptionsUtility.RULE_INDEX,
new CICSDiscardOptionsUtility(context, errors));
spOptionsMap.put(
CICSCreateSPOptionsCheckUtility.RULE_INDEX,
new CICSCreateSPOptionsCheckUtility(context, errors));
}
/**
* Entrypoint to check CICS rule options
Expand Down
7 changes: 7 additions & 0 deletions server/engine/src/main/resources/LanguageKeywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ ATTACHTIME=
ATTLS=
ATTRIBUTE=
ATTRIBUTES=
ATTRLEN=
AUDALARMST=
AUDIT=
AUDITLEVEL=
Expand Down Expand Up @@ -1546,6 +1547,7 @@ LOW_VALUE=
LOW_VALUES=
LPAD=
LPASTATUS=
LSRPOOL=
LSRPOOLNUM=
LTERM=
LTRIM=
Expand Down Expand Up @@ -1822,6 +1824,7 @@ NOMDECK=
NOMDT=
NOMINVALUE=
NONAME=
NOLOG=
NONE=
NONTERMREL=
NONUM=
Expand Down Expand Up @@ -2067,6 +2070,7 @@ PARTIAL=
PARTITION=
PARTITIONED=
PARTITIONING=
PARTITIONSET=
PARTITIONSST=
PARTN=
PARTNER=
Expand Down Expand Up @@ -2567,6 +2571,7 @@ SERVER_NAME=
SERVICE=
SERVSTATUS=
SESSION=
SESSIONS=
SESSIONTYPE=
SESSION_USER=
SESSTOKEN=
Expand Down Expand Up @@ -2945,6 +2950,7 @@ TRANDUMPING=
TRANISOLATE=
TRANPRIORITY=
TRANSACTION=
TRANSCLASS=
TRANSFORM=
TRANSID=
TRANSLATE=
Expand Down Expand Up @@ -2987,6 +2993,7 @@ TYPENAME=
TYPENAMELEN=
TYPENS=
TYPENSLEN=
TYPETERM=
TYPES=
UCASE=
UCTRANST=
Expand Down
Loading
Loading