Skip to content

Commit

Permalink
update: added order flexibility to sub command and removed string con…
Browse files Browse the repository at this point in the history
…cats
  • Loading branch information
chacebot committed Sep 4, 2024
1 parent 3156c32 commit 7f5afcb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ cics_address_set: (SET cics_data_area USING cics_ref |

/** ALLOCATE (all of them) */
cics_allocate: ALLOCATE (cics_allocate_appc_partner | cics_allocate_appc_mro_lut61_sysid | cics_allocate_lut61_session);
cics_allocate_appc_mro_lut61_sysid: SYSID cics_data_area (PROFILE cics_name | NOQUEUE | STATE cics_cvda | cics_handle_response)*;
cics_allocate_lut61_session: SESSION cics_name (PROFILE cics_name | NOQUEUE | cics_handle_response)*;
cics_allocate_appc_partner: PARTNER cics_name (NOQUEUE | STATE cics_cvda | cics_handle_response)*;
cics_allocate_appc_mro_lut61_sysid: (SYSID cics_data_area | PROFILE cics_name | NOQUEUE | STATE cics_cvda | cics_handle_response)+;
cics_allocate_lut61_session: (SESSION cics_name | PROFILE cics_name | NOQUEUE | cics_handle_response)+;
cics_allocate_appc_partner: (PARTNER cics_name | NOQUEUE | STATE cics_cvda | cics_handle_response)+;

/** ASKTIME */
cics_asktime: ASKTIME cics_handle_response? (ABSTIME (cics_data_area | cics_handle_response)+)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,19 @@ public <E extends ParserRuleContext> void checkOptions(E ctx) {
}

private void checkAppcPartner(CICSParser.Cics_allocate_appc_partnerContext ctx) {

checkHasMandatoryOptions(ctx.PARTNER(), ctx, "PARTNER");
List<RuleContextData> contexts = new ArrayList<>();
contexts.add(new RuleContextData(ctx.PARTNER(), "PARTNER"));
contexts.add(new RuleContextData(ctx.NOQUEUE(), "NOQUEUE", ErrorSeverity.WARNING));
contexts.add(new RuleContextData(ctx.STATE(), "STATE"));
harvestResponseHandlers(ctx.cics_handle_response(), contexts);
checkDuplicates(contexts);
}

private void checkAppcMroLut61Sysid(CICSParser.Cics_allocate_appc_mro_lut61_sysidContext ctx) {

checkHasMandatoryOptions(ctx.SYSID(), ctx, "SYSID");
List<RuleContextData> contexts = new ArrayList<>();
contexts.add(new RuleContextData(ctx.SYSID(), "SYSID"));
contexts.add(new RuleContextData(ctx.PROFILE(), "PROFILE"));
contexts.add(new RuleContextData(ctx.NOQUEUE(), "NOQUEUE", ErrorSeverity.WARNING));
contexts.add(new RuleContextData(ctx.STATE(), "STATE"));
Expand All @@ -71,8 +73,9 @@ private void checkAppcMroLut61Sysid(CICSParser.Cics_allocate_appc_mro_lut61_sysi
}

private void checkLut61Session(CICSParser.Cics_allocate_lut61_sessionContext ctx) {

checkHasMandatoryOptions(ctx.SESSION(), ctx, "SESSION");
List<RuleContextData> contexts = new ArrayList<>();
contexts.add(new RuleContextData(ctx.SESSION(), "SESSION"));
contexts.add(new RuleContextData(ctx.PROFILE(), "PROFILE"));
contexts.add(new RuleContextData(ctx.NOQUEUE(), "NOQUEUE", ErrorSeverity.WARNING));
harvestResponseHandlers(ctx.cics_handle_response(), contexts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ private void checkMap(CICSParser.Cics_receive_mapContext ctx) {
if (ctx.TERMINAL().isEmpty()) checkHasIllegalOptions(ctx.INPARTN(), "INPARTN");

List<RuleContextData> contexts = new ArrayList<>();
contexts.add(new RuleContextData(ctx.MAP(), "MAP"));
contexts.add(new RuleContextData(ctx.MAPSET(), "MAPSET"));
contexts.add(new RuleContextData(ctx.cics_into_set(), "INTO or SET"));
contexts.add(new RuleContextData(ctx.FROM(), "FROM"));
Expand All @@ -140,6 +141,7 @@ private void checkMapMappingDev(CICSParser.Cics_receive_map_mappingdevContext ct
checkHasMandatoryOptions(ctx.FROM(), ctx, "FROM");

List<RuleContextData> contexts = new ArrayList<>();
contexts.add(new RuleContextData(ctx.MAP(), "MAP"));
contexts.add(new RuleContextData(ctx.MAPPINGDEV(), "MAPPINGDEV"));
contexts.add(new RuleContextData(ctx.FROM(), "FROM"));
contexts.add(new RuleContextData(ctx.LENGTH(), "LENGTH"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,23 @@
* <p>This class tests all variations of the ALLOCATE command found in the link above.
*/
public class TestCICSAllocate {
private static final String ALLOCATE = "ALLOCATE ";
private static final String PARTNER = "PARTNER({$varFour}) ";
private static final String SESSION = "SESSION({$varFive}) ";
private static final String SYSID = "SYSID({$varOne}) ";
private static final String PROFILE = "PROFILE({$varSix}) ";
private static final String STATE = "STATE({$varFour}) ";
private static final String NOQUEUE = "NOQUEUE ";

private static final String APPC_ALL_OPTIONS_VALID_ONE =
ALLOCATE + PARTNER + NOQUEUE + STATE.trim();
"ALLOCATE PARTNER({$varFour}) NOQUEUE STATE({$varFour})";

private static final String APPC_ALL_OPTIONS_VALID_TWO =
ALLOCATE + SYSID + PROFILE + NOQUEUE + STATE.trim();
"ALLOCATE SYSID({$varOne}) PROFILE({$varSix}) NOQUEUE STATE({$varFour})";

private static final String APPC_INVALID_ONE =
ALLOCATE + PARTNER + "{PROFILE|error1}(100) " + NOQUEUE + "STATE(err)";
"ALLOCATE PARTNER({$varFour}) {PROFILE|error1}(100) NOQUEUE STATE(err)";

private static final String LUT61_ALL_OPTIONS_VALID_ONE =
ALLOCATE + SESSION + PROFILE + NOQUEUE.trim();
"ALLOCATE SESSION({$varFive}) PROFILE({$varSix}) NOQUEUE";

private static final String LUT61_INVALID_ONE =
ALLOCATE + "SESSION(100) " + "PROFILE(100) " + "{STATE|errorOne}(100)";
"ALLOCATE SESSION(100) PROFILE(100) {STATE|errorOne}(100)";

private static final String MRO_ALL_OPTIONS_VALID_ONE =
ALLOCATE + SYSID + PROFILE + NOQUEUE + STATE.trim();
"ALLOCATE SYSID({$varOne}) PROFILE({$varSix}) NOQUEUE STATE({$varFour})";

@Test
void testAPPCAllOptionsValidOne() {
Expand Down

0 comments on commit 7f5afcb

Please sign in to comment.