diff options
author | Benedikt Böhm <bb@xnull.de> | 2009-05-20 14:26:05 +0200 |
---|---|---|
committer | Benedikt Böhm <bb@xnull.de> | 2009-05-20 14:26:05 +0200 |
commit | 614065172ad58893fa2eab25fdfe25d1aa21a483 (patch) | |
tree | 86ddaec0087132349c36327c9d2aff9b091fffb5 /src/front/token.py | |
parent | ad57a52ac92e0745a0006897374357d449189293 (diff) | |
download | swppy-614065172ad58893fa2eab25fdfe25d1aa21a483.tar.gz swppy-614065172ad58893fa2eab25fdfe25d1aa21a483.tar.xz swppy-614065172ad58893fa2eab25fdfe25d1aa21a483.zip |
remove symbol table from lexer
Diffstat (limited to '')
-rw-r--r-- | src/front/token.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/front/token.py b/src/front/token.py index 4cf646a..31159bf 100644 --- a/src/front/token.py +++ b/src/front/token.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # date: 20 Mai 2009 -class Tag: +class Tag(object): + __slots__ = ["name"] + def __init__(self, name): self.name = name @@ -52,23 +54,26 @@ Tag.RETURN = Tag("RETURN") Tag.ASSIGN = Tag("ASSIGN") Tag.FUNCTION = Tag("FUNCTION") -class Token: - tag = None +class Token(object): + __slots__ = ["tag"] def __init__(self, tag): self.tag = tag - return def __repr__(self): return "<Token: %s>" % self.tag -class ValueToken(Token): - value = None +class LeafToken(Token): + __slots__ = ["value"] - def __init__(self, tag, value): + def __init__(self, tag, value = None): Token.__init__(self, tag) self.value = value - return def __repr__(self): - return "<Token: %s, Value: %s>" % (self.tag, self.value.__str__()) + if self.value: + return "<LeafToken: %s, Value: %s>" % (self.tag, self.value.__str__()) + return "<LeafToken: %s>" % self.tag + +class NodeToken(Token): + pass |