Mercurial > lcfOS
comparison python/ppci/errors.py @ 289:bd2593de3ff8
Semifix burn2
author | Windel Bouwman |
---|---|
date | Thu, 21 Nov 2013 15:46:50 +0100 |
parents | a747a45dcd78 |
children | 6aa721e7b10b |
comparison
equal
deleted
inserted
replaced
288:a747a45dcd78 | 289:bd2593de3ff8 |
---|---|
9 class CompilerError(Exception): | 9 class CompilerError(Exception): |
10 def __init__(self, msg, loc=None): | 10 def __init__(self, msg, loc=None): |
11 self.msg = msg | 11 self.msg = msg |
12 self.loc = loc | 12 self.loc = loc |
13 if loc: | 13 if loc: |
14 assert type(loc) is SourceLocation, '{0} must be SourceLocation'.format(type(loc)) | 14 assert type(loc) is SourceLocation, \ |
15 '{0} must be SourceLocation'.format(type(loc)) | |
15 self.row = loc.row | 16 self.row = loc.row |
16 self.col = loc.col | 17 self.col = loc.col |
17 else: | 18 else: |
18 self.row = self.col = 0 | 19 self.row = self.col = 0 |
19 | 20 |
20 def __repr__(self): | 21 def __repr__(self): |
21 if self.row: | 22 if self.row: |
22 return 'Compilererror: "{0}" at row {1}'.format(self.msg, self.row) | 23 return '"{0}" at row {1}'.format(self.msg, self.row) |
23 else: | 24 else: |
24 return 'Compilererror: "{0}"'.format(self.msg) | 25 return '"{0}"'.format(self.msg) |
25 | 26 |
26 def printError(source, e): | 27 def printError(source, e): |
27 def printLine(row, txt): | 28 def printLine(row, txt): |
28 print(str(row)+':'+txt) | 29 print(str(row)+':'+txt) |
29 if e.row == 0 or True: | 30 if e.row == 0 or True: |