diff python/ppci/errors.py @ 152:b73bc14a3aa3

Light coupling ide and c3 frontend
author Windel Bouwman
date Sat, 02 Mar 2013 09:56:12 +0100
parents e5263f74b287
children 0b5b2ee6b435
line wrap: on
line diff
--- a/python/ppci/errors.py	Fri Mar 01 17:13:56 2013 +0100
+++ b/python/ppci/errors.py	Sat Mar 02 09:56:12 2013 +0100
@@ -3,30 +3,12 @@
    Diagnostic utils
 """
 
-from collections import namedtuple
-
-SourceLocation = namedtuple('SourceLocation', ['row', 'col'])
-SourceRange = namedtuple('SourceRange', ['p1', 'p2'])
-
-class CompilerException(Exception):
+class CompilerError(Exception):
   def __init__(self, msg, loc):
     self.msg = msg
     self.loc = loc
   def __repr__(self):
-     return 'error {0} at {1}'.format(self.msg, self.loc)
-  def __str__(self):
-     return 'error {0} at {1}'.format(self.msg, self.loc)
-
-class ErrorNode:
-   def __init__(self, row, col, msg):
-      self.row, self.col = row,col
-      self.msg = msg
-
-def Error(msg, node=None):
-   if node is None:
-      raise CompilerException(msg)
-   else:
-      raise CompilerException(msg, node.row, node.col)
+     return 'Compilererror {0} at {1}'.format(self.msg, self.loc)
 
 def printError(source, e):
      def printLine(row, txt):
@@ -53,9 +35,11 @@
         for r in range(ro+1, afterrow+1):
           printLine(r, lines[r-1])
 
-class Diagnostics:
+class DiagnosticsManager:
    def __init__(self):
       self.diags = []
-   def diag(self, d):
+   def addDiag(self, d):
       self.diags.append(d)
+   def error(self, msg, loc):
+      self.addDiag(CompilerError(msg, loc))