[Mumps2Py:] [119] added support for the fnumber and get intrinsic functions.

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


Revision: 119
Author:   pgallot
Date:     2008-02-18 20:55:55 +0000 (Mon, 18 Feb 2008)

Log Message:
-----------
added support for the fnumber and get intrinsic functions.

Modified Paths:
--------------
    trunk/mumps2py/tok2python.py


Modified: trunk/mumps2py/tok2python.py
===================================================================
--- trunk/mumps2py/tok2python.py	2008-02-18 20:53:00 UTC (rev 118)
+++ trunk/mumps2py/tok2python.py	2008-02-18 20:55:55 UTC (rev 119)
@@ -198,7 +198,7 @@
                        (param.varname, tuplify(translation, param.indices))
         else:
             data_str = "Mf_data(globals(), '%s')" % param.varname
-        return data_str                
+        return data_str
 
     def translate_intr_extract(translation, token):
         """ translates the Mumps Intrinsic function EXTRACT to Python"""
@@ -235,6 +235,32 @@
                                    "incorrect number of parameters")
         return find_str
                            
+    def translate_intr_fnumber(translation, token):
+        """translates the Mumps Intrinsic function FNUMBER to Python"""
+        assert(len(token.params) in (2, 3))
+        translation.add_cl_import()
+        precis_str = ""
+        if len(token.params) == 3:
+            precis_str = ", %s" % translate_expr(translation, token.params[2])
+        fnumber_str = "Mf_fnumber(%s, %s%s)" % \
+                      (translate_expr(translation, token.params[0]),
+                       translate_expr(translation, token.params[1]),
+                       precis_str)
+        return fnumber_str
+
+    def translate_intr_get(translation, token):
+        """translates the Mumps Intrinsic function GET to Python"""
+        assert(len(token.params) in (1, 2))
+        var = token.params[0]
+        alt_val_str = ""
+        assert(var.is_var() and var.is_indexed())
+        if len(token.params) == 2:
+            alt_val_str = ", %s" % translate_expr(translation, token.params[1])
+        get_str = "%s.get(%s%s)" % (var.varname,
+                                    tuplify(translation, var.indices),
+                                    alt_val_str)
+        return get_str
+
     def translate_intr_horolog(translation, token):
         """ translates the Mumps Intrinsic variable HOROLOG to Python"""
         translation.add_cl_import()
@@ -274,7 +300,7 @@
         """ translates the Mumps Intrinsic function ORDER to Python"""
         translation.add_cl_import()
         param = token.params[0]
-        dir_str=""
+        dir_str = ""
         if len(param.indices) > 1:
             param_index = tuplify(translation, param.indices)
         else:
@@ -332,7 +358,7 @@
         return reverse_str
 
     def translate_intr_select(translation, token):
-        """ translates the Mumps Intrinsic function REVERSE to Python"""
+        """ translates the Mumps Intrinsic function SELECT to Python"""
         assert((len(token.params) % 2) != 1)
         translation.add_cl_import()
         select_str = "Mf_select(("
@@ -479,6 +505,8 @@
         F_DATA: translate_intr_data,
         F_EXTRACT: translate_intr_extract,
         F_FIND: translate_intr_find,
+        F_FNUMBER: translate_intr_fnumber,
+        F_GET: translate_intr_get,
         F_JUSTIFY: translate_intr_justify,
         F_LENGTH: translate_intr_length,
         F_ORDER: translate_intr_order,


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