Skip to content

Commit

Permalink
do-while and repeat-until loops
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlano authored May 2, 2024
1 parent 7dcbd22 commit 93668c3
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 16 deletions.
8 changes: 6 additions & 2 deletions cg/C2UMLstatement.cstl
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ expressionStatement::
_1 ; |-->_1`C2UMLupdateForm

compoundStatement::
{ _1 } |--> (_1 )
{ _1 } |--> (_1 skip)
{ } |--> skip

selectionStatement::
Expand All @@ -498,11 +498,15 @@ if ( _1 ) _2 else _3 |--> if _1\n then\n _2\n else\n _3\n

switch ( _1 ) _2 |--> for _switchx : Integer.subrange(1,1)\n do (\n var _switchVar := _1 ;\n _2\n )\n


iterationStatement::
while ( _1 ) _2 |-->_1`C2UMLpresideeffect while _1\n do ( \n _2\n _1`C2UMLpresideeffect )\n
do _1 while ( _2 ) ; |-->_1 ;\n_2`C2UMLpresideeffect while _2\n do ( \n _1\n _2`C2UMLpresideeffect )\n

do _1 while ( _2 ) ; |-->while true\n do ( \n _1\n _2`C2UMLpresideeffect ; if _2 then skip else break\n )\n

for ( _1 ) _2 |-->_1`forInitialisation while _1`forTest\n do\n (_2 \n _1`forIncrement\n )\n


jumpStatement::
goto _1 ; |--> _1() ;\n
continue ; |--> continue ;\n
Expand Down
14 changes: 13 additions & 1 deletion cg/JS2UML.cstl
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,31 @@ if ( _1 ) _2 else _3 |--> if _1 then\n _2\n else (\n _3\n )
if ( _1 ) _2 |--> if _1 then\n _2\n else skip

iterationStatement::
do _1 while ( _2 ) _3 |-->_1 ;\n while _2 do (\n _1 )\n
do _1 while ( _2 ) _3 |--> while true do (\n _1 ;\n if _2 then skip else break\n )\n

while ( _1 ) _2 |--> while _1 do (\n _1`updateForm_2 )\n

for ( _1 ; _2 ; _3 ) _4 |-->_1`updateForm ;\n while _2 do (\n _4; _3`updateForm )\n

for ( _1 ; _2 ; ) _3 |-->_1`updateForm ;\n while _2 do (\n _3 )\n

for ( _1 ; ; _2 ) _3 |-->_1`updateForm ;\n while true do (\n _3; _2`updateForm )\n

for ( _1 ; ; ) _2 |-->_1`updateForm ;\n while true do (\n _2 )\n

for ( ; _1 ; _2 ) _3 |--> while _1 do (\n _3; _2`updateForm )\n

for ( ; _1 ; ) _2 |--> while _1 do (\n _2 )\n

for ( ; ; _1 ) _2 |--> while true do (\n _2; _1`updateForm )\n

for ( ; ; ) _1 |--> while true do (\n _1 )\n

for ( _1 in _2 ) _3 |--> for _1`variableName : _2`domain do (\n _3 )\n

for ( _1 of _2 ) _3 |--> for _1`variableName : _2 do (\n _3 )\n


domain::
_1 |-->_1->keys()<when> _1 Map
_1 |-->Integer.subrange(0,_1->size()-1)
Expand Down
4 changes: 2 additions & 2 deletions cg/VB2UML.cstl
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,8 @@ doLoopStmt::
DO \r\n _1 \r\n LOOP |--> while true do (\n_1\n skip)
DO WHILE _1 \r\n _2 \r\n LOOP |--> while _1 do (\n_2\n skip)
DO UNTIL _1 \r\n _2 \r\n LOOP |--> while not(_1) do (\n_2\n skip)
DO \r\n _1 \r\n LOOP WHILE _2 |--> _1 ;\n while _2 do (\n_1\n skip)
DO \r\n _1 \r\n LOOP UNTIL _2 |--> _1 ;\n while not(_2) do (\n_1\n skip)
DO \r\n _1 \r\n LOOP WHILE _2 |--> while true do (\n_1\n if _2 then skip else break)
DO \r\n _1 \r\n LOOP UNTIL _2 |--> while true do (\n_1\n if _2 then break else skip)



Expand Down
5 changes: 4 additions & 1 deletion cg/cgJava2UML.cstl
Original file line number Diff line number Diff line change
Expand Up @@ -3264,7 +3264,9 @@ _1 : _2 |-->_2
_1 : _2 ; |-->_2

while _1 _2 |--> while _1 do _2 ;

if _1 _2 else _3 |--> if _1 then _2 else _3 ;

if _1 _2 |--> if _1 then _2 else skip ;

for ( _1 ) _2 |--> _1 _2 _1`forIncrement ) ;
Expand All @@ -3280,7 +3282,8 @@ assert _1 ; |--> assert _1 ;

try _1 _2 _* |--> try _1 _2 _*
try _1 _2 |--> try _1 _2
do _1 while _2 ; |-->_1 ;\n while _2 do _1

do _1 while _2 ; |--> while true do (_1 if _2 then skip else break) ;

_1 ; |-->_1`updateForm ;<when> _1 expression
_1 ; |-->_1
Expand Down
69 changes: 62 additions & 7 deletions cg/cobol2UML.cstl
Original file line number Diff line number Diff line change
Expand Up @@ -2514,23 +2514,35 @@ END-PERFORM |-->
_1 END-PERFORM |--> ( _1 skip) ;\n<when> _1 statement
_1 _* END-PERFORM |--> ( _1_* skip) ; \n


performProcedureStatement::
_1 _2 |--> _2 self._1_Call() _2`performIncrement ;\n
_1 _2 |--> _2 self._1_Call() _2`performIncrement ;\n<when> _2 performType
_1 |--> self._1_Call() ;\n

_1 THROUGH _2 _3 |--> _3 self._1_thru__2() ;\n _3`performIncrement<when> _3 performType
_1 THROUGH _2 |--> self._1_thru__2() ;\n

_1 THRU _2 _3 |--> _3 self._1_thru__2() ;\n _3`performIncrement<when> _3 performType
_1 THRU _2 |--> self._1_thru__2() ;\n


performType::
_1 |--> for _performTimes : Integer.subrange(1,_1) do <when> _1 performTimes

_1 |--> repeat <when> _1 performUntil, _1`isTestAfter true
_1 |--> while not(_1) do <when> _1 performUntil

_1 |--> _1`performVariable := _1`performInitialValue;\n repeat <when> _1 performVarying, _1`isTestAfter true
_1 |--> _1`performVariable := _1`performInitialValue;\n while not(_1`performCondition) do (<when> _1 performVarying


performIncrement::
_1 |--><when> _1 performTimes

_1 |--> until _1`performCondition<when> _1 performUntil, _1`isTestAfter true
_1 |--><when> _1 performUntil

_1 |-->; _1`performVaryingIncrement until _1`performCondition<when> _1`isTestAfter true
_1 |-->; _1`performVaryingIncrement)


Expand All @@ -2539,14 +2551,16 @@ _1 TIMES |-->_1


performUntil::
_1 UNTIL _2 |-->_2
_1 UNTIL _2 |-->_2<when> _1 performTestClause
UNTIL _1 |-->_1


performVarying::
_1 _2 |-->_2<when> _1 performTestClause, _2 performVaryingClause
_1 _2 |-->_1<when> _1 performVaryingClause, _2 performTestClause
_1 |-->_1<when> _1 performVaryingClause


performVaryingIncrement::
_1 _2 |-->_2`performVaryingClauseIncrement<when> _1 performTestClause, _2 performVaryingClause
_1 _2 |-->_1`performVaryingClauseIncrement<when> _1 performVaryingClause, _2 performTestClause
Expand All @@ -2558,66 +2572,101 @@ _1 _2 |-->_2`performVaryingVariable<when> _1 performTestClause, _2 performVaryi
_1 _2 |-->_1`performVaryingVariable<when> _1 performVaryingClause, _2 performTestClause
_1 |-->_1`performVaryingVariable<when> _1 performVaryingClause


performInitialValue::
_1 _2 |-->_2`performVaryingInitialValue<when> _1 performTestClause, _2 performVaryingClause
_1 _2 |-->_1`performVaryingInitialValue<when> _1 performVaryingClause, _2 performTestClause
_1 |-->_1`performVaryingInitialValue<when> _1 performVaryingClause


performCondition::
UNTIL _1 |-->_1
_1 UNTIL _2 |-->_2<when> _1 performTestClause

_1 _2 |-->_2`performVaryingCondition<when> _1 performTestClause, _2 performVaryingClause
_1 _2 |-->_1`performVaryingCondition<when> _1 performVaryingClause, _2 performTestClause
_1 |-->_1`performVaryingCondition<when> _1 performVaryingClause


performVaryingClause::
VARYING _1 |-->_1<when> _1 performVaryingPhrase
VARYING _1 _2 |-->_1<when> _1 performVaryingPhrase, _2 performAfter
VARYING _1 _* |-->_1<when> _1 performVaryingPhrase
VARYING _1 _2 |-->_1 _2<when> _1 performVaryingPhrase, _2 performAfter
VARYING _1 _* |-->_1 _*<when> _1 performVaryingPhrase


performVaryingVariable::
VARYING _1 |-->_1`performVaryingVariable<when> _1 performVaryingPhrase

VARYING _1 _2 |-->_1`performVaryingVariable<when> _1 performVaryingPhrase, _2 performAfter

VARYING _1 _* |-->_1`performVaryingVariable<when> _1 performVaryingPhrase

_1 _2 _3 _4 |-->_1


performVaryingInitialValue::
VARYING _1 |-->_1`performVaryingInitialValue<when> _1 performVaryingPhrase

VARYING _1 _2 |-->_1`performVaryingInitialValue<when> _1 performVaryingPhrase, _2 performAfter

VARYING _1 _* |-->_1`performVaryingInitialValue<when> _1 performVaryingPhrase

_1 _2 _3 _4 |-->_2


performVaryingCondition::
VARYING _1 |-->_1`performVaryingCondition<when> _1 performVaryingPhrase

VARYING _1 _2 |-->_1`performVaryingCondition<when> _1 performVaryingPhrase, _2 performAfter

VARYING _1 _* |-->_1`performVaryingCondition<when> _1 performVaryingPhrase

_1 _2 _3 _4 |-->_4


performVaryingClauseIncrement::
VARYING _1 |-->_1`performVaryingClauseIncrement<when> _1 performVaryingPhrase

VARYING _1 _2 |-->_1`performVaryingClauseIncrement<when> _1 performVaryingPhrase, _2 performAfter

VARYING _1 _* |-->_1`performVaryingClauseIncrement<when> _1 performVaryingPhrase

_1 _2 _3 _4 |-->_1 := _1 + _3


performVaryingPhrase::
_1 _2 _3 _4 |--> while not(_4) do<when> _2 performFrom, _3 performBy, _4 performUntil


performAfter::
AFTER _1 |--> <when> _1 performVaryingPhrase
AFTER _1 |--> _1`performVariable := _1`performInitialValue;\n while not(_1`performCondition) do (<when> _1 performVaryingPhrase


performFrom::
FROM _1 |-->_1


performBy::
BY _1 |-->_1


performTestClause::
WITH TEST BEFORE |-->
WITH TEST AFTER |-->
TEST BEFORE |-->
TEST AFTER |-->


isTestAfter::
_1 UNTIL _2 |-->_1`isTestAfter
UNTIL _1 |-->false
WITH TEST BEFORE |-->false
WITH TEST AFTER |-->true
TEST BEFORE |-->false
TEST AFTER |-->true
_1 _2 |-->_1`isTestAfter<when> _1 performTestClause, _2 performVaryingClause


readStatement::
READ _1 NEXT RECORD _2 _3 END-READ |--> if _1_Position > _1->size() then (_3 skip) else ( _1_Record := _1[_1_Position] ; _2 := _1_Record ) ;\n<when> _2 readInto, _3 atEndPhrase
READ _1 NEXT RECORD _2 _3 |--> if _1_Position > _1->size() then (_3 skip) else (_1_Record := _1[_1_Position] ; _2 := _1_Record ) ;\n<when> _2 readInto, _3 atEndPhrase
Expand Down Expand Up @@ -3674,7 +3723,10 @@ _1 |-->, _1


arrayAccesses::
, |-->
, _1 |-->_1
_1 |-->_1
, _* |-->_*`recurse
_1 _* |-->_1][_*`recurse


Expand All @@ -3690,11 +3742,14 @@ _1 |-->_1
qualifiedDataName::
_1 |-->_1


qualifiedDataNameFormat1::
_1 _2 |-->_2$_1<when> _1`ambiguousName true
_1 _2 |-->(_2).subrange(_1`startingPosition,_1`endingPosition)<when> _2 qualifiedInData
_1 _2 |-->_1
_1 |-->_1


fieldWidth::
_1 _2 |-->(_1`endingPosition - _1`startingPosition + 1)
_1 |-->_1`fieldWidth<when> _1 qualifiedDataName
Expand Down Expand Up @@ -3744,8 +3799,8 @@ IN _1 |-->
OF _1 |-->

inTable::
IN _1 |-->_1.
OF _1 |-->_1.
IN _1 |-->_1
OF _1 |-->_1

alphabetName::
_1 |-->_1
Expand Down
6 changes: 3 additions & 3 deletions cg/pascal2UML.cstl
Original file line number Diff line number Diff line change
Expand Up @@ -1121,9 +1121,9 @@ while _1 do _2 |-->\n while _1 do (_2)


repeatStatement::
REPEAT _1 UNTIL _2 |-->\n _1;\n while not(_2) do (_1)
Repeat _1 Until _2 |-->\n _1;\n while not(_2) do (_1)
repeat _1 until _2 |-->\n _1;\n while not(_2) do (_1)
REPEAT _1 UNTIL _2 |-->\n while true do (_1 ;\n if _2 then break else skip)
Repeat _1 Until _2 |-->\n while true do (_1 ;\n if _2 then break else skip)
repeat _1 until _2 |-->\n while true do (_1 ;\n if _2 then break else skip)


forStatement::
Expand Down

0 comments on commit 93668c3

Please sign in to comment.