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

Bugfix/nw24000512/when with complex expression #488

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 9 additions & 7 deletions rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ keyword_likerec : KEYWORD_LIKEREC OPEN_PAREN intrecname=simpleExpression
(COLON (SPLAT_ALL | SPLAT_INPUT | SPLAT_OUTPUT | SPLAT_KEY))?
CLOSE_PAREN;
keyword_noopt : KEYWORD_NOOPT;
keyword_occurs : KEYWORD_OCCURS OPEN_PAREN (numeric_constant=number | function | identifier) CLOSE_PAREN;
keyword_occurs : KEYWORD_OCCURS OPEN_PAREN (numeric_constant=number | function | identifier) CLOSE_PAREN;
keyword_opdesc : KEYWORD_OPDESC;
keyword_options : KEYWORD_OPTIONS OPEN_PAREN identifier (COLON identifier)* CLOSE_PAREN;
keyword_overlay : KEYWORD_OVERLAY OPEN_PAREN name=simpleExpression (COLON (SPLAT_NEXT | pos=simpleExpression))? CLOSE_PAREN;
Expand Down Expand Up @@ -394,10 +394,11 @@ onError:
statement*
;
selectstatement:
beginselect
whenstatement*
(beginselect endselect) |
(beginselect
whenstatement+
other?
endselect
endselect)
;

other:
Expand Down Expand Up @@ -439,9 +440,10 @@ when:
indicators=cs_indicators
factor1=factor
csWHEN
andConds=csANDxx*
orConds=csORxx*
)
| (op_when FREE_SEMI free_linecomments? )
statement*
;
csWHENxx:
CS_FIXED
Expand Down Expand Up @@ -1755,7 +1757,7 @@ csOperationAndExtendedFactor2:
// operation=OP_EVAL

//|operation=OP_IF
|operation=OP_CALLP operationExtender=cs_operationExtender?
operation=OP_CALLP operationExtender=cs_operationExtender?
//|operation=OP_DOW
//|operation=OP_ELSEIF
;
Expand Down Expand Up @@ -2374,7 +2376,7 @@ bif_code: BIF_ABS


free: ((baseExpression FREE_SEMI free_linecomments? ) | exec_sql); // (NEWLINE |COMMENTS_EOL);
c_free: (((expression) free_linecomments? ) | exec_sql);
c_free: ((expression free_linecomments? ) | exec_sql);

control: opCode indicator_expr;
exec_sql: EXEC_SQL WORDS+ SEMI ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ open class MULANGT12LoopFlowGotoTest : MULANGTTest() {
val expected = listOf("DO_1(A04_N50_CNT(10) A04_STR(1) A04_END(10) A04_CNT(11)) DO_2(A04_N50_CNT(15) A04_CNT(16))")
assertEquals(expected, "smeup/T12_A04_P19".outputOf())
}

/**
* SELECT-WHEN with complex boolean expression
* @see #236
*/
@Test
fun executeT12_A05_P12() {
val expected = listOf("PrimoWhen")
assertEquals(expected, "smeup/T12_A05_P12".outputOf())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
D £DBG_Str S 150 VARYING

C SETOFF 1011
C SETON 12
C SELECT
C WHEN *IN12
C EVAL £DBG_Str='PrimoWhen'
C WHEN (*IN10 AND *IN11)
C OR *IN12
C EVAL £DBG_Str='SecondoWhen'
C OTHER
C EVAL £DBG_Str='Other'
C ENDSL
C £DBG_Str DSPLY