Explorar o código

Semantics visitor no longer reasons about the global keyword either

Yentl Van Tendeloo %!s(int64=9) %!d(string=hai) anos
pai
achega
71b047c278
Modificáronse 1 ficheiros con 3 adicións e 5 borrados
  1. 3 5
      interface/HUTN/hutn_compiler/semantics_visitor.py

+ 3 - 5
interface/HUTN/hutn_compiler/semantics_visitor.py

@@ -330,16 +330,14 @@ class SemanticsVisitor(Visitor):
         self.visit_vardecl(tree)
 
     def visit_vardecl(self, tree):
-        var_global = len(tree.get_tail()) == 3
-
-        type_spec = tree.get_tail()[var_global+0]
-        var_id = tree.get_tail()[var_global+1]
+        type_spec = tree.get_child("type_specifier")
+        var_id = tree.get_child("ID")
 
         var_type = types_mv.string_to_type(type_spec.get_text())
         var_name = var_id.get_text()
 
         symbol = st.Symbol(var_name, var_type,
-                        is_global=var_global or self.current_funcdecl is None)
+                        is_global=self.current_funcdecl is None)
 
         try:
             self.symbol_table.add(symbol)