Commit 0d3e1de7 authored by Sergio Costas's avatar Sergio Costas

Now recognized the ENUMs

parent e5e2e7f0
......@@ -8,6 +8,9 @@ tree = lib.read_file(sys.argv[1],False)
if tree is None:
sys.exit()
variables,functions = lib.process_tree(tree)
lib.process_functions(tree,variables,functions)
try:
variables,functions = lib.process_tree(tree)
lib.process_functions(tree,variables,functions)
except:
pass
lib.print_errors()
......@@ -439,6 +439,12 @@ class crusty(object):
return retval
def _process_enum(self,enum_node,var_container):
counter = 0
for node in enum_node.enum_data:
var_container[0][node.name] = {"properties": 0, "status":crusty.STATUS_GLOBAL, "init_line": node.line, "pointer": 0 }
def process_tree(self,tree):
""" Process the main tree with the global variables and the function definitions and declarations """
......@@ -446,6 +452,10 @@ class crusty(object):
function_container = {}
# First fill all the global variables and the function declarations
for node in tree:
if (node.type == "TYPE_SPECIFIER"):
if (node.enum_data is not None):
self._process_enum(node,var_container)
continue
if node.type == "EMPTY_DECLARATOR":
continue
if node.type == "VARIABLE_DEFINITION":
......@@ -492,6 +502,10 @@ class crusty(object):
for counter in range(len(tree)):
node = tree[counter]
if (node.type == "TYPE_SPECIFIER"):
if (node.enum_data is not None):
self._process_enum(node,var_container)
continue
if node.type == "CRUSTY_DEBUG":
print("Debug: '{:s}'".format(str(var_container)))
continue
......
......@@ -411,6 +411,7 @@ enumerator
: IDENTIFIER { $$ = $1;
$$->name = strdup($1->data); }
| IDENTIFIER '=' constant_expression { $$ = $1;
$$->name = strdup($1->data);
$$->assignment = $3; }
;
......
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