Mercurial > lcfOS
comparison python/ppci/errors.py @ 251:6ed3d3a82a63
Added another c3 example. First import attempt
author | Windel Bouwman |
---|---|
date | Mon, 29 Jul 2013 20:23:13 +0200 |
parents | b10d46e5c8dd |
children | 7416c923a02a |
comparison
equal
deleted
inserted
replaced
250:f5fba5b554d7 | 251:6ed3d3a82a63 |
---|---|
12 if loc: | 12 if loc: |
13 assert type(loc) is SourceLocation, '{0} must be SourceLocation'.format(type(loc)) | 13 assert type(loc) is SourceLocation, '{0} must be SourceLocation'.format(type(loc)) |
14 self.row = loc.row | 14 self.row = loc.row |
15 self.col = loc.col | 15 self.col = loc.col |
16 else: | 16 else: |
17 self.row = self.col = None | 17 self.row = self.col = 0 |
18 | 18 |
19 def __repr__(self): | 19 def __repr__(self): |
20 if self.row: | 20 if self.row: |
21 return 'Compilererror: "{0}" at row {1}'.format(self.msg, self.row) | 21 return 'Compilererror: "{0}" at row {1}'.format(self.msg, self.row) |
22 else: | 22 else: |
23 return 'Compilererror: "{0}"'.format(self.msg) | 23 return 'Compilererror: "{0}"'.format(self.msg) |
24 | 24 |
25 def printError(source, e): | 25 def printError(source, e): |
26 def printLine(row, txt): | 26 def printLine(row, txt): |
27 print(str(row)+':'+txt) | 27 print(str(row)+':'+txt) |
28 if e.loc.row == 0: | 28 if e.row == 0: |
29 print('Error: {0}'.format(e.msg)) | 29 print('Error: {0}'.format(e.msg)) |
30 else: | 30 else: |
31 lines = source.split('\n') | 31 lines = source.split('\n') |
32 ro, co = e.row, e.col | 32 ro, co = e.row, e.col |
33 prerow = ro - 2 | 33 prerow = ro - 2 |
34 if prerow < 1: | 34 if prerow < 1: |
35 prerow = 1 | 35 prerow = 1 |