diff python/ppci/common.py @ 194:b01429a5d695

Fixed test
author Windel Bouwman
date Wed, 29 May 2013 22:36:37 +0200
parents 6b2bec5653f1
children e41e4109addd
line wrap: on
line diff
--- a/python/ppci/common.py	Sun May 26 23:58:59 2013 +0200
+++ b/python/ppci/common.py	Wed May 29 22:36:37 2013 +0200
@@ -1,7 +1,16 @@
 from collections import namedtuple
 
 # Token is used in the lexical analyzer:
-Token = namedtuple('Token', 'typ val loc')
+class Token:
+    def __init__(self, typ, val, loc=None):
+        self.typ = typ
+        self.val = val
+        if loc is None:
+            loc = SourceLocation(0, 0, 0)
+        assert type(loc) is SourceLocation
+        self.loc = loc
+    def __repr__(self):
+        return 'Token({0}, {1})'.format(self.typ, self.val)
 
 class SourceLocation:
    def __init__(self, row, col, ln):