Mercurial > lcfOS
diff python/ppci/errors.py @ 215:c1ccb1cb4cef
Major changes in c3 frontend
author | Windel Bouwman |
---|---|
date | Fri, 05 Jul 2013 13:00:03 +0200 |
parents | 5e391d9a3381 |
children | 1c7364bd74c7 |
line wrap: on
line diff
--- a/python/ppci/errors.py Fri Jul 05 11:18:58 2013 +0200 +++ b/python/ppci/errors.py Fri Jul 05 13:00:03 2013 +0200 @@ -11,9 +11,14 @@ self.loc = loc if loc: assert type(loc) is SourceLocation, '{0} must be SourceLocation'.format(type(loc)) + self.row = loc.row + self.col = loc.col + else: + self.row = self.col = None + def __repr__(self): - if self.loc: - return 'Compilererror: "{0}" at row {1}'.format(self.msg, self.loc.row) + if self.row: + return 'Compilererror: "{0}" at row {1}'.format(self.msg, self.row) else: return 'Compilererror: "{0}"'.format(self.msg) @@ -24,7 +29,7 @@ print('Error: {0}'.format(e.msg)) else: lines = source.split('\n') - ro, co = e.loc.row, e.loc.col + ro, co = e.row, e.col prerow = ro - 2 if prerow < 1: prerow = 1 @@ -45,12 +50,16 @@ class DiagnosticsManager: def __init__(self): self.diags = [] + def addDiag(self, d): self.diags.append(d) + def error(self, msg, loc): self.addDiag(CompilerError(msg, loc)) + def clear(self): del self.diags[:] + def printErrors(self, src): if len(self.diags) > 0: print('{0} Errors'.format(len(self.diags)))