summaryrefslogblamecommitdiffstats
path: root/src/front/symbol.py
blob: 879403faf543d6ff28021d789fe3e7aab6161cf8 (plain) (tree)

































                                                                            
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")

class Symbol(object):
    __slots__ = ['cls', 'type', 'value']

    def __init__(self, value, type = SymbolType.INT, cls = SymbolClass.VAR):
        self.value = value
        self.type = type
        self.cls = cls