Commit 9feaaaa4 authored by Sergio Costas's avatar Sergio Costas

Now evaluates functions

parent f4bb039e
......@@ -4,60 +4,10 @@ import sys
from crusty import crusty
lib = crusty.crusty("lexyacclib/crusty.h","lexyacclib/crusty.so")
tree = lib.read_file(sys.argv[1])
tree = lib.read_file(sys.argv[1],True)
if tree is None:
sys.exit()
def print_param(node):
data = ""
if node.t_signed:
data += "signed "
if node.t_unsigned:
data += "unsigned "
if node.t_char:
data += "char "
if node.t_int:
data += "int "
if node.t_void:
data += "void "
if node.name is not None:
data += node.name
return data
def procnode(node):
if node is None:
return None
t,data2 = lib.process_node(node)
if data2 is None:
return node
if t == "VARIABLE_DEFINITION":
listdata = data2
else:
listdata = [data2]
for data in listdata:
data.child1 = procnode(node.child1)
data.child2 = procnode(node.child2)
data.child3 = procnode(node.child3)
data.child4 = procnode(node.child4)
data.right = procnode(node.right)
data.next = procnode(node.next)
if t == "VARIABLE_DEFINITION":
return data2
else:
return None
def print_nodes(nodelist, tabs = 0):
for element in nodelist:
print(" "*tabs,end = "")
print("Tipo: {:s}; Nombre: {:s}".format(str(element.type),str(element.name)))
if element.child1 is not None:
print_nodes(element.child1, tabs+1)
#print_nodes(tree)
try:
variables,functions = lib.process_tree(tree)
lib.process_functions(tree,variables,functions)
except:
pass
variables,functions = lib.process_tree(tree)
lib.process_functions(tree,variables,functions)
lib.print_errors()
This diff is collapsed.
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