diff --git a/rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4 b/rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4 index 764f54437..cacccaf10 100644 --- a/rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4 +++ b/rpgJavaInterpreter-core/src/main/antlr/RpgLexer.g4 @@ -316,6 +316,7 @@ SPLAT_FILE: '*'[fF][iI][lL][eE]; SPLAT_GETIN: '*'[gG][eE][tT][iI][nN]; SPLAT_HIVAL: '*'[hH][iI][vV][aA][lL]; SPLAT_INIT: '*'[iI][nN][iI][tT]; +SPLAT_ALL_INDICATORS: '*' [iI] [nN] [ ] [ ]; SPLAT_INDICATOR : ( '*' [iI] [nN] [0-9] [0-9] | '*' [iI] [nN] [a-zA-Z] [a-zA-Z] | '*' [iI] [nN] '(' [0-9] [0-9] ')' ); @@ -1032,6 +1033,7 @@ CS_Factor2_SPLAT_GETIN : SPLAT_GETIN {35+6<= getCharPositionInLine() && getCharP CS_Factor2_SPLAT_HIVAL : SPLAT_HIVAL {35+6<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_HIVAL); CS_Factor2_SPLAT_INIT : SPLAT_INIT {35+5<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_INIT); CS_Factor2_SPLAT_INDICATOR : SPLAT_INDICATOR {35+4<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_INDICATOR); +CS_Factor2_SPLAT_ALL_INDICATORS : SPLAT_ALL_INDICATORS {35+4<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_ALL_INDICATORS); CS_Factor2_SPLAT_INZSR : SPLAT_INZSR {35+6<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_INZSR); CS_Factor2_SPLAT_IN : SPLAT_IN {35+3<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_IN); CS_Factor2_SPLAT_JOBRUN : SPLAT_JOBRUN {35+7<= getCharPositionInLine() && getCharPositionInLine()<=48}? -> type(SPLAT_JOBRUN); diff --git a/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 b/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 index 8d7c243e7..601d94e5a 100644 --- a/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 +++ b/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 @@ -2581,6 +2581,7 @@ SPLAT_ALL | SPLAT_HIVAL | SPLAT_INIT | SPLAT_INDICATOR + | SPLAT_ALL_INDICATORS | SPLAT_INZSR | SPLAT_IN | SPLAT_JOBRUN diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt index 57d876596..7d9f012aa 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt @@ -29,6 +29,7 @@ import java.math.MathContext import java.math.RoundingMode import java.time.temporal.ChronoUnit import java.time.ZoneId +import java.util.HashMap import kotlin.math.abs import kotlin.math.sqrt @@ -676,8 +677,20 @@ class ExpressionEvaluation( override fun eval(expression: AssignmentExpr) = throw RuntimeException("AssignmentExpr should be handled by the interpreter: $expression") - override fun eval(expression: GlobalIndicatorExpr) = - throw RuntimeException("PredefinedGlobalIndicatorExpr should be handled by the interpreter: $expression") + override fun eval(expression: GlobalIndicatorExpr): Value { + + for (i in 1..99) + if (interpreterStatus.indicators[i] == null) + interpreterStatus.indicators[i] = BooleanValue(false) + val ret = interpreterStatus.indicators.map { it.value } + return StringValue( + ret.map { + if (it.value) { + 1 } else { + 0 + } + }.joinToString { it.toString() }) + } override fun eval(expression: ParmsExpr): Value { return IntValue(interpreterStatus.params.toLong()) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt index 652239edf..a95dc634d 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt @@ -22,9 +22,7 @@ data class IndicatorExpr(val index: IndicatorKey, override val position: Positio @Serializable data class GlobalIndicatorExpr(override val position: Position? = null) : AssignableExpression(position) { - override fun size(): Int { - TODO("not implemented") // To change body of created functions use File | Settings | File Templates. - } + override fun size(): Int = 99 override fun evalWith(evaluator: Evaluator): Value = evaluator.eval(this) } diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt index dcd4189c7..a489f75ed 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt @@ -667,6 +667,11 @@ internal fun SymbolicConstantsContext.toAst(conf: ToAstConfiguration = ToAstConf position = position ) } + this.SPLAT_ALL_INDICATORS() != null -> { + GlobalIndicatorExpr( + position = position + ) + } this.SPLAT_ALL() != null -> { val content: LiteralContext = this.parent.getChild(1) as LiteralContext AllExpr(content.toAst(conf), position) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt index f70d2ec78..73d41a937 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt @@ -2202,4 +2202,11 @@ Test 6 val expected = listOf("A1_OK", "A2_OK", "A3_OK", "N1_OK", "N2_OK", "N3_OK", "DS_OK", "DSA1_OK", "DSA2_OK") assertEquals(expected, "RESET01".outputOf()) } + + @Test + fun executeMOVEAIN() { + val expected = listOf("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000") + assertASTCanBeProduced("MOVEAIN", printTree = true) + assertEquals(expected, "MOVEAIN".outputOf()) + } } diff --git a/rpgJavaInterpreter-core/src/test/resources/MOVEAIN.rpgle b/rpgJavaInterpreter-core/src/test/resources/MOVEAIN.rpgle new file mode 100644 index 000000000..2254cbfe2 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/MOVEAIN.rpgle @@ -0,0 +1,13 @@ + D* £DBG_Ind S 99 + D £DBG_Sch S 1 DIM(99) + * + C MOVEL *ON *IN44 + C SETON 88 + C* MOVEA(P) *IN £DBG_Ind + C MOVEA(P) *IN £DBG_Sch + * Expected: + * '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000' + * + C* £DBG_Ind DSPLY + C £DBG_Sch DSPLY + C SETON LR \ No newline at end of file