[Mumps2Py:] [125] added M_eval to handle M indirection expressions. |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
Revision: 125
Author: pgallot
Date: 2008-02-22 03:34:21 +0000 (Fri, 22 Feb 2008)
Log Message:
-----------
added M_eval to handle M indirection expressions.
Modified Paths:
--------------
trunk/mumps2py/mumpsCL.py
Modified: trunk/mumps2py/mumpsCL.py
===================================================================
--- trunk/mumps2py/mumpsCL.py 2008-02-22 03:28:51 UTC (rev 124)
+++ trunk/mumps2py/mumpsCL.py 2008-02-22 03:34:21 UTC (rev 125)
@@ -24,6 +24,15 @@
# value. F i:1:1:10 iterates from 1 to 10, inclusive. the equivalent would be
# range(1, 11)
+def M_eval(line, loc_adr_space):
+ """parses, translates, and evaluates a string as a Mumps expression"""
+ from mumps2py import parse_expr, Translation, translate_expr
+
+ token = parse_expr(line, 0)
+ translation = Translation(None)
+ expression = translate_expr(translation, token)
+ return eval(expression, loc_adr_space)
+
def Mf_horolog(timestamp = None):
"""function that emulates Mumps $Horolog variable."""
if timestamp == None: