Mercurial > lcfOS
view python/ppci/common.py @ 231:521567d17388
simplify blink.c3
author | Windel Bouwman |
---|---|
date | Sat, 13 Jul 2013 20:20:44 +0200 |
parents | b01429a5d695 |
children | e41e4109addd |
line wrap: on
line source
from collections import namedtuple # Token is used in the lexical analyzer: 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): self.row = row self.col = col self.length = ln SourceRange = namedtuple('SourceRange', ['p1', 'p2'])