summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/front/__init__.py0
-rw-r--r--src/front/scope.py24
-rw-r--r--src/front/symbol.py32
-rw-r--r--src/front/type.py12
4 files changed, 20 insertions, 48 deletions
diff --git a/src/front/__init__.py b/src/front/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/src/front/__init__.py
+++ /dev/null
diff --git a/src/front/scope.py b/src/front/scope.py
index 2cc3018..0df8729 100644
--- a/src/front/scope.py
+++ b/src/front/scope.py
@@ -1,20 +1,6 @@
-class Scope(object, DictMixin):
- def __init__(self, parent):
- self.parent = parent
- self.__symbols = {}
+class Scope(object):
+ __shared_state = {}
+ functions = {}
- def __getitem__(self, key):
- try:
- return self.__symbols[key]
- except KeyError:
- return self.parent[key]
-
- def __setitem__(self, key, item):
- self.__symbols[key] = item
-
- def keys(self):
- keys = self.__symbols.keys()
- for key in self.parent.keys():
- if key not in keys:
- keys.append(key)
- return keys
+ def __init__(self):
+ self.__dict__ = self.__shared_state
diff --git a/src/front/symbol.py b/src/front/symbol.py
index 879403f..b93b778 100644
--- a/src/front/symbol.py
+++ b/src/front/symbol.py
@@ -1,34 +1,8 @@
-class SymbolClass(object):
- def __init__(self, name):
- self.name = name
-
- def __str__(self):
- return self.name
-
- def __repr__(self):
- return "<SymbolClass: %s>" % self
-
-SymbolClass.CONST = SymbolClass("CONST")
-SymbolClass.VAR = SymbolClass("VAR")
-SymbolClass.FUNC = SymbolClass("FUNC")
-
-class SymbolType(object):
- def __init__(self, name):
- self.name = name
-
- def __str__(self):
- return self.name
-
- def __repr__(self):
- return "<SymbolType: %s>" % self
-
-SymbolType.INT = SymbolType("INT")
-SymbolType.BOOL = SymbolType("BOOL")
+from type import DataType
class Symbol(object):
- __slots__ = ['cls', 'type', 'value']
+ __slots__ = ['type', 'value']
- def __init__(self, value, type = SymbolType.INT, cls = SymbolClass.VAR):
+ def __init__(self, value, type = DataType.INT):
self.value = value
self.type = type
- self.cls = cls
diff --git a/src/front/type.py b/src/front/type.py
new file mode 100644
index 0000000..a8bd8c7
--- /dev/null
+++ b/src/front/type.py
@@ -0,0 +1,12 @@
+class DataType(object):
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+ def __repr__(self):
+ return "<DataType: %s>" % self
+
+DataType.INT = DataType("INT")
+DataType.BOOL = DataType("BOOL")