[Mumps2Py:] [29] added (partial) support for the LENGTH intrinsic function.

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


Revision: 29
Author:   pgallot
Date:     2008-01-19 16:06:58 +0000 (Sat, 19 Jan 2008)

Log Message:
-----------
added (partial) support for the LENGTH intrinsic function.

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


Modified: trunk/mumps2py/tok2python.py
===================================================================
--- trunk/mumps2py/tok2python.py	2008-01-18 21:02:27 UTC (rev 28)
+++ trunk/mumps2py/tok2python.py	2008-01-19 16:06:58 UTC (rev 29)
@@ -148,6 +148,15 @@
                                    "incorrect number of parameters")
         return extract_str
                  
+    def translate_intr_length(translation, token):
+        """ translates the Mumps Intrinsic function LENGTH to Python"""
+        if len(token.params) == 1:
+            length_str = "len(%s)" % \
+                       translate_expr(translation, token.params[0])
+            return length_str
+        else:
+            raise TranslationError(translation, token, "idiom not implemented")
+
     def translate_local_var(translation, token):
         """ translates a local variable into a Python variable"""
         if not token.__dict__.has_key('indices'):
@@ -216,6 +225,7 @@
         F_ASCII: translate_intr_ascii,
         F_CHAR: translate_intr_char,
         F_EXTRACT: translate_intr_extract,
+        F_LENGTH: translate_intr_length,
         EXPR: translate_expr_list}
 
     if expr_transl_dict.has_key(token.toktype):


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