[Mumps2Py:] First Message.

[ Thread Index | Date Index | More lists.mumps2py.org/discuss Archives ]


Yesterday, January 10th, was Donald E. Knuth's 70th birthday.
It was also the first time that Mumps2Py translated an entire sample file of code into Python.

This (simpleconditionals.mps):
 set i=1,j=2,k=3
 if i=1 write "yes",! ; yes
 if i<j write "yes",! ; yes
 if i<j,k>j write "yes",! ; yes
 if i<j&k>j write "yes",! ; does not write
 if i>j&(k>j) write "yes",! ; yes
 if i write "yes",! ; yes
 if 'i write "yes",! ; does not write
 if '(i=0) write "yes",! ; yes
 if i=0!(j=2) write "yes",! ; yes


became simpleconditionals.py:
i = 1
j = 2
k = 3
if (i == 1):
    print "yes", "\n",
    #  yes
if (i < j):
    print "yes", "\n",
    #  yes
if (i < j) or (k > j):
    print "yes", "\n",
    #  yes
if (((i < j) and k) > j):
    print "yes", "\n",
    #  does not write
if ((i > j) and (k > j)):
    print "yes", "\n",
    #  yes
if i:
    print "yes", "\n",
    #  yes
if (not i):
    print "yes", "\n",
    #  does not write
if (not (i == 0)):
    print "yes", "\n",
    #  yes
if ((i == 0) or (j == 2)):
    print "yes", "\n",
    #  yes

It's a trivial translation of 3 Mumps commands, expressions, and comments, and it could be more elegant but getting to this point took about two months of effort, so I think it's a significant milestone.

Mumps2Py is more complete on the parsing side than on the translating side.
On the translating side, there are more commands (including FOR, GOTO, DO), intrinsic functions and variables, entryrefs, indexed local variables (dictionaries) and global variables (shared buffer dictionaries), indirection, and more.

Translating all of that into elegant Python code should be  do-able (elegant, that is, if you're willing to overlook what may need to go into the Mumps Compatibility Library), and it should a fun, technical Computer Science-type project.

If you're reading this from the archives, (because I'm currently the only one on the mailing list :) please feel free to join in and contribute!

Cheers,
-Patrick


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/