Update lympha

parent 489ec773
......@@ -6,8 +6,6 @@
# 2. Building linked lists.
# 3. Running the linked list.
#import ast
import subprocess
import sys
......@@ -80,6 +78,33 @@ exe_objects = list()
CLIcom_segment = 0
from ast import NodeVisitor
class Evaluator(NodeVisitor):
def __init__(self, **kwargs):
self._namespace = kwargs
def visit_Name(self, node):
return self._namespace[node.id]
def visit_Num(self, node):
return node.n
def visit_NameConstant(self, node):
return node.value
def visit_UnaryOp(self, node):
val = self.visit(node.operand)
return operators[type(node.op)](val)
def visit_BinOp(self, node):
lhs = self.visit(node.left)
rhs = self.visit(node.right)
return operators[type(node.op)](lhs, rhs)
def generic_visit(self, node):
raise ValueError("malformed node or string: " + repr(node))
#Construction of the section model of the linked list.
class Statement(dict):
MARKER = object()
......@@ -259,46 +284,30 @@ def mapfunc():
#pattern = re.compile(r'\d*|\w*|\+|\-|\/|\*|\(|\)')
iteratorUntouched = pattern.split(string)
iteratorTouched = pattern.split(string)
int indexMain
for varUntouched in iteratorUntouched:
for checkobj in range(0,len(object_list)):
if object_list[checkobj].name == varUntouched:
# Loop through untouched variable
for indexWord in range(len(varUntouched)):
r = re.compile(rf'(indexWord}')
m = r.search(string)
#replace
#1 delete the old variable
#2 replace with the new
if m : ### = object_list[checkobj].value
indexMain += 1
#iteratorTouched[index] = object_list[checkobj].value
# Loop through all untouched
for indexWord in range(len(groupUntouched)):
#0 indexing var for position
#1 count position for first letter in untouchedvariable and length of variable
#2 count character length of the variables value
#3 adjust the indexing var ( -untouched +value)
r = ['ApplC3LDJXGEDCP7', '10']
print(re.sub(r'{.+?}', lambda match: r.pop(0), s, count=len(r)))
if group != "" or group != None :
name = object_list[checkobj].name
if group == name:
gstring = str(object_list[checkobj].value)
if gstring != "":
endstring += gstring
#break
endstring = re.sub("{|}", "", str(endstring))
print("EVAL %s" % (endstring))
eqlist = dict()
for varWord in iteratorUntouched:
for objWord in range(len(object_list)):
if object_list[objWord].name == varWord:
eqlist[varWord] = object_list[objWord].statement_value
#no value???
print("OJ %s" % statement_value)
eqString = str()
print("STRING %s\nITERATOR %s" % (string, iteratorUntouched))
for index, eqKey in enumerate(eqlist):
if index == 0 :
eqstring = ("%s=%s" % (eqKey, eqlist[eqKey]))
else:
eqstring = ("%s, %s=%s" % (eqKey, eqlist[eqKey], eqString))
endnum = int()
endnum = eval(endstring)
#print("ENDNUM %s"%endnum)
try:
v = Evaluator(eval(eqString))
endstring = v.visit(object_list[key].statement_value)
endnum = eval(endstring)
except:
pass
if object_list[key].operator1 == "equiv" and float(object_list[key].global_relative_variable1) == float(str(endnum)):
print ("%s == %s ; exe" % (float(object_list[key].global_relative_variable1), float(str(endnum))))
......@@ -566,8 +575,7 @@ def lexer():
#For evaluations
# Check if operator:
elif "==" in sides[1] or "!=" in sides[1] or "<=" in sides[1] or ">=" in sides[1] or "<" in sides[1] or ">" in sides[1] :
print("XXX")
elif ("==" in sides[1] or "!=" in sides[1] or "<=" in sides[1] or ">=" in sides[1] or "<" in sides[1] or ">" in sides[1] ) and not "->" in sides[1]:
#eval_pattern = re.compile(r"(==)|(!=)|(<)|(>)|(<=)|(>=)")
#if eval_pattern.match(sides[1]) :
# if re.compile(".*==.*").match(sides[1]) :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment