-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #547 from smeup/feature/LS24002977/i-specs-externa…
…l-fields-renaming Feature/ls24002977/i specs external fields renaming
- Loading branch information
Showing
4 changed files
with
222 additions
and
3 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
...r-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/input_specifications.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.smeup.rpgparser.parsing.parsetreetoast | ||
|
||
import com.smeup.rpgparser.RpgParser | ||
import com.strumenta.kolasu.mapping.toPosition | ||
import com.strumenta.kolasu.model.Position | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
sealed class InputSpecification | ||
|
||
@Serializable | ||
data class FileNameInputSpecification( | ||
val name: String, | ||
val position: Position? | ||
) : InputSpecification() | ||
|
||
@Serializable | ||
data class ExternalFieldInputSpecification( | ||
val originalName: String, | ||
val newName: String, | ||
val controlLevelIndicator: String?, | ||
val matchingFieldsIndicator: String?, | ||
val position: Position? | ||
) : InputSpecification() | ||
|
||
/** | ||
* Links the external definition to its specifications. | ||
*/ | ||
data class InputSpecificationGroup( | ||
val fileName: FileNameInputSpecification, | ||
val specifications: List<InputSpecification> | ||
) | ||
|
||
fun RpgParser.ControlLevelIndicatorContext.toIndicator(): String? { | ||
return when { | ||
this.ControlLevelIndicator() != null -> this.ControlLevelIndicator().text | ||
else -> null | ||
} | ||
} | ||
|
||
fun RpgParser.MatchingFieldsIndicatorContext.toIndicator(): String? { | ||
return when { | ||
this.MatchingRecordIndicator() != null -> this.MatchingRecordIndicator().text | ||
else -> null | ||
} | ||
} | ||
|
||
fun RpgParser.Is_external_fieldContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): InputSpecification { | ||
val originalName = this.IF_Name().text.trim() | ||
val newName = this.IF_FieldName().text.trim() | ||
val controlIndicator = this.controlLevelIndicator().toIndicator() | ||
val matchField = this.matchingFieldsIndicator().toIndicator() | ||
|
||
// TODO: Add result indicators | ||
// val resultIndicators = this.resultIndicator() | ||
|
||
return ExternalFieldInputSpecification( | ||
originalName, | ||
newName, | ||
controlIndicator, | ||
matchField, | ||
toPosition(conf.considerPosition) | ||
) | ||
} | ||
|
||
fun RpgParser.Ispec_fixedContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): InputSpecification { | ||
return when { | ||
this.is_external_field() != null -> this.is_external_field().toAst(conf) | ||
this.IS_FileName() != null -> { | ||
val fileName = this.IS_FileName().text.trim() | ||
|
||
// TODO: Add support for indicators | ||
FileNameInputSpecification( | ||
fileName, | ||
toPosition(conf.considerPosition) | ||
) | ||
} | ||
else -> todo(conf = conf) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
rpgJavaInterpreter-core/src/test/resources/smeup/MU500901.rpgle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
*==================================================================== | ||
* smeup V6R1.023DV | ||
* Nome sorgente : MU500901 | ||
* Sorgente di origine : QTEMP/SRC(MU500901) | ||
* Esportato il : 20240612 092228 | ||
*==================================================================== | ||
V* ============================================================== | ||
V* MODIFICHE Ril. T Au Descrizione | ||
V* gg/mm/aa nn.mm i xx Breve descrizione | ||
V* ============================================================== | ||
V* 29/05/24 MUTEST GUAGIA Creazione | ||
V*===================================================================== | ||
O * OBIETTIVO | ||
O * Test atomico LIKE, OCCURS | ||
V* ============================================================== | ||
FMULANGTL IF E K DISK | ||
F RENAME(MULANGR:MULANG3) | ||
* ------------------------------------------------------------- | ||
/COPY QILEGEN,MULANG_D_D | ||
/COPY QILEGEN,£TABB£1DS | ||
/COPY QILEGEN,£PDS | ||
IMULANG3 | ||
I MLSYST TSSYST | ||
I MLLIBR TSLIBR | ||
I MLFILE TSFILE | ||
I MLTIPO TATIPO | ||
I MLPROG TBPROG | ||
I MLPSEZ AAAAAA | ||
I MLPPAS BBBBBB | ||
I MLPDES CCCCCC | ||
*--------------------------------------------------------------------- | ||
RD* M A I N | ||
*--------------------------------------------------------------------- | ||
C EVAL £DBG_Pgm = 'MU500901' | ||
C EVAL £DBG_Sez = 'A09' | ||
C EVAL £DBG_Fun = '*INZ' | ||
C EXSR £DBG | ||
C EXSR SEZ_A09 | ||
C EXSR £DBG | ||
C EVAL £DBG_Fun = '*END' | ||
C EXSR £DBG | ||
C SETON LR | ||
*--------------------------------------------------------------------- | ||
RD* Test atomico | ||
*--------------------------------------------------------------------- | ||
C SEZ_A09 BEGSR | ||
OA* A£.CDOP() | ||
D* Test atomico specifiche I | ||
C EVAL £DBG_Pas='P01' | ||
* | ||
C TSLANG5K KLIST | ||
C KFLD TSSYST | ||
C KFLD TATIPO | ||
C KFLD TBPROG | ||
C KFLD AAAAAA | ||
C KFLD BBBBBB | ||
C EVAL TSSYST='IBMI' | ||
C EVAL TATIPO='3' | ||
C EVAL TBPROG='MULANGT12' | ||
C EVAL AAAAAA='A03' | ||
C EVAL BBBBBB='P01' | ||
* | ||
C EVAL £DBG_Str='' | ||
C TSLANG5K SETLL MULANGTL | ||
C READ MULANG3 | ||
* | ||
C EVAL £DBG_Str='TSSYST(' + %TRIM(TSSYST) + | ||
C ') TSLIBR(' + %TRIM(TSLIBR) + | ||
C ') TSFILE(' + %TRIM(TSFILE) + | ||
C ') TATIPO(' + %TRIM(TATIPO) + | ||
C ') TBPROG(' + %TRIM(TBPROG) + | ||
C ') AAAAAA(' + %TRIM(AAAAAA) + | ||
C ') BBBBBB(' + %TRIM(BBBBBB) + | ||
C ') CCCCCC(' + %TRIM(CCCCCC) + ')' | ||
C ENDSR | ||
*--------------------------------------------------------------------- | ||
/COPY QILEGEN,MULANG_D_C |