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

Fixed test
author Windel Bouwman
date Wed, 29 May 2013 22:36:37 +0200
parents 6b2bec5653f1
children e41e4109addd
comparison
equal deleted inserted replaced
193:f091e7d70996 194:b01429a5d695
1 from collections import namedtuple 1 from collections import namedtuple
2 2
3 # Token is used in the lexical analyzer: 3 # Token is used in the lexical analyzer:
4 Token = namedtuple('Token', 'typ val loc') 4 class Token:
5 def __init__(self, typ, val, loc=None):
6 self.typ = typ
7 self.val = val
8 if loc is None:
9 loc = SourceLocation(0, 0, 0)
10 assert type(loc) is SourceLocation
11 self.loc = loc
12 def __repr__(self):
13 return 'Token({0}, {1})'.format(self.typ, self.val)
5 14
6 class SourceLocation: 15 class SourceLocation:
7 def __init__(self, row, col, ln): 16 def __init__(self, row, col, ln):
8 self.row = row 17 self.row = row
9 self.col = col 18 self.col = col