Skip to content

Commit

Permalink
Pascal and Python improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlano authored Dec 19, 2023
1 parent 5f19a65 commit 4cdbdb9
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 18 deletions.
44 changes: 39 additions & 5 deletions cg/pascal2UML.cstl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ _1 _* |-->_1`recordClassDefinitions<when> _1 typeDefinitionPart
_1 _* |-->_*`recurse


labelDeclarationPart::
label _* |-->

label::
_1 |-->label__1


constantDefinitionPart::
const _* |-->_*\n

Expand Down Expand Up @@ -428,6 +435,10 @@ BOOLEAN |-->boolean
INTEGER |-->int
REAL |-->double
STRING |-->String
Char |-->String
Boolean |-->boolean
Integer |-->int
Real |-->double
char |-->String
boolean |-->boolean
integer |-->int
Expand Down Expand Up @@ -533,13 +544,27 @@ _1 |-->\n _1`third := _1`first.read()


writeStatement::
_1 |-->\n output.print("" + (_1`first))<when> _1`numberOfArguments 1
_1 |-->\n _1`first.print("" + (_1`third))
_1 |-->\n output.print("" + _1`first)
_1 _* |-->\n _1`first.print("" _*`writeArguments)


writelnStatement::
_1 |-->\n output.println("" + (_1`first))<when> _1`numberOfArguments 1
_1 |-->\n _1`first.println("" + (_1`third))
_1 |-->\n output.println("" + _1)
_1 _* |-->\n _1.println("" _*`writeArguments)


writeArguments::
, |--> +

_1 _2 _3 |--> StringLib.format("%_2._3f", Sequence{_1})<when> _1`ocltype double
_1 _2 _3 |--> StringLib.format("%_2._3d", Sequence{_1})<when> _1`ocltype int
_1 _2 _3 |--> StringLib.format("%_2._3s", Sequence{_1})

_1 _2 |--> StringLib.format("%_2f", Sequence{_1})<when> _1`ocltype double
_1 _2 |--> StringLib.format("%_2d", Sequence{_1})<when> _1`ocltype int
_1 _2 |--> StringLib.format("%_2s", Sequence{_1})

_1 |--> _1


rewriteStatement::
Expand All @@ -557,8 +582,9 @@ _1 |-->_1
_1 _* |-->_1



parameterwidth::
: _1 |-->
: _1 |-->_1


structuredStatement::
Expand Down Expand Up @@ -716,6 +742,14 @@ sqr ( _1 ) |-->(_1)->sqr()
sqrt ( _1 ) |-->(_1)->sqrt()

chr ( _1 ) |-->(_1)->byte2char()
ord ( _1 ) |-->(_1)->char2byte()<when> _1`ocltype String
ord ( _1 ) |-->_1`typName.ord(_1)

succ ( _1 ) |-->((_1)->char2byte() + 1)->byte2char()<when> _1`ocltype String
succ ( _1 ) |-->_1`typName.succ(_1)

pred ( _1 ) |-->((_1)->char2byte() - 1)->byte2char()<when> _1`ocltype String
pred ( _1 ) |-->_1`typName.pred(_1)

eof ( _1 ) |-->_1.getEof()

Expand Down
32 changes: 19 additions & 13 deletions cg/python2UML.cstl
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,13 @@ _1 , _* |-->_1`asSetting_*`recurse


def_parameter::
_1 = _2 |-->_1`parameterName : String<when> _2 String, _1 1ary <action> _1`parameterName String
_1 = _2 |-->_1`parameterName : int<when> _2 int, _1 1ary <action> _1`parameterName int
_1 = _2 |-->_1`parameterName : double<when> _2 real, _1 1ary <action> _1`parameterName real
_1 = _2 |-->_1
_1 = _2 |-->_1`parameterName : String<when> _2 String, _1 1ary <action> _1`parameterName String, _1`defined true
_1 = _2 |-->_1`parameterName : int<when> _2 int, _1 1ary <action> _1`parameterName int, _1`defined true
_1 = _2 |-->_1`parameterName : double<when> _2 real, _1 1ary <action> _1`parameterName real, _1`defined true
_1 = _2 |-->_1<action> _1`defined true

_1 |-->_1<action> _1`defined true
* |-->
_1 |-->_1


paramDefaultCode::
Expand Down Expand Up @@ -1152,7 +1152,7 @@ _1 |-->


trailerUpdateForm::
. append _1 |-->->including_1
. append _1 |-->->append_1
. extend _1 |-->->union(_1->characters())<when> _1 String
. extend _1 |-->->union_1
. insert _1 |-->.insertAt(_1`firstArg+1, _1`lastArg)
Expand Down Expand Up @@ -1502,6 +1502,8 @@ try : _1 |-->_1`hasValueReturn
try : _1 _* |-->true<when> _1`hasValueReturn true
try : _1 _* |-->_*`recurse

with _1 : _2 |-->_2`hasValueReturn

elif _1 : _2 |-->_2`hasValueReturn

else : _1 |-->_1`hasValueReturn
Expand Down Expand Up @@ -1572,6 +1574,8 @@ try : _1 |-->_1`hasYieldStatement
try : _1 _* |-->true<when> _1`hasYieldStatement true
try : _1 _* |-->_*`recurse

with _1 : _2 |-->_2`hasYieldStatement

elif _1 : _2 |-->_2`hasYieldStatement

else : _1 |-->_1`hasYieldStatement
Expand Down Expand Up @@ -1977,13 +1981,13 @@ _* |-->


funcdef::
async def _1 ( _2 ) -> _3 : _4 |--> operation _1(_2) : _3`ocltype\n pre: true post: true\n activity:\n_4;\n\n
def _1 ( _2 ) -> _3 : _4 |--> operation _1(_2) : _3`ocltype\n pre: true post: true\n activity:\n_4;\n\n
async def _1 ( _2 ) -> _3 : _4 |--> operation _1(_2) : _3`ocltype\n pre: true post: true\n activity:\n_2`defaultParamSettings_4;\n\n
def _1 ( _2 ) -> _3 : _4 |--> operation _1(_2) : _3`ocltype\n pre: true post: true\n activity:\n_2`defaultParamSettings_4;\n\n

async def _1 ( _2 ) : _3 |--> operation _1(_2) : OclAny\n pre: true post: true\n activity:\n_3;\n\n<when> _3`hasValueReturn true
async def _1 ( _2 ) : _3 |--> operation _1(_2)\n pre: true post: true\n activity:\n_3;\n\n
async def _1 ( _2 ) : _3 |--> operation _1(_2) : OclAny\n pre: true post: true\n activity:\n_2`defaultParamSettings_3;\n\n<when> _3`hasValueReturn true
async def _1 ( _2 ) : _3 |--> operation _1(_2)\n pre: true post: true\n activity:\n_2`defaultParamSettings_3;\n\n

def _1 ( _2 ) : _3 |--> operation _1(_2) : OclAny\n pre: true post: true\n activity:\n_3;\n\n<when> _3`hasValueReturn true
def _1 ( _2 ) : _3 |--> operation _1(_2) : OclAny\n pre: true post: true\n activity:\n_2`defaultParamSettings_3;\n\n<when> _3`hasValueReturn true
def _1 ( _2 ) : _3 |--> operation _1(_2)\n pre: true post: true\n activity:\n_2`defaultParamSettings_3;\n\n

async def _1 ( ) -> _2 : _3 |--> operation _1() : _2`ocltype\n pre: true post: true\n activity:\n_3;\n\n
Expand All @@ -1999,7 +2003,7 @@ def _1 ( ) : _2 |--> operation _1()\n pre: true post: true\n activity:\n_2;\n


methodDefinition::
def __init__ ( _1 ) : _2 |-->_2`attributeDefinitions\n operation initialise(_1`parametersTail) : OclAny\n pre: true post: true\n activity:\n_2;\n return self;\n\n
def __init__ ( _1 ) : _2 |-->_2`attributeDefinitions\n operation initialise(_1`parametersTail) : _$\n pre: true post: true\n activity:\n_2;\n return self;\n\n

def _1 ( _2 ) -> _3 : _4 |-->\n operation _1(_2`parametersTail) : _3`ocltype\n pre: true post: true\n activity:\n_4;\n\n

Expand Down Expand Up @@ -2045,7 +2049,7 @@ class _1 ( _2 ) : _3 |-->class _1 extends _2 {\n static operation new_1() : _1\

class _1 ( ) : _2 |-->class _1 {\n static operation new_1() : _1\n pre: true\n post: _1->exists( _x | result = _x );\n\n_2`classcontent}\n\n<action> _1 Class

class _1 : _2 |-->class _1 {\n static operation new_1() : _1\n pre: true\n post: _1->exists( _x | result = _x );\n\n_2`classcontent}\n\n<action> _1 Class
class _1 : _2 |-->class _1 {\n static operation new_1() : _1\n pre: true\n post: _1->exists( _x | result = _x );\n\n_2`classcontent}\n\n<action> _1 Class, _$ _1


classcontent::
Expand Down Expand Up @@ -2124,6 +2128,8 @@ except _1 , _2 : _3 |-->_3`nestedAttributeDefinitions

finally : _1 |-->_1`nestedAttributeDefinitions

with _1 : _2 |-->_2`nestedAttributeDefinitions

global _* |-->_*`attributeDecln
nonlocal _* |-->_*`attributeDecln

Expand Down

0 comments on commit 4cdbdb9

Please sign in to comment.