[pypy-svn] r34583 - pypy/dist/pypy/lang/prolog/interpreter

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Nov 13 21:31:06 CET 2006


Author: cfbolz
Date: Mon Nov 13 21:31:04 2006
New Revision: 34583

Modified:
   pypy/dist/pypy/lang/prolog/interpreter/main.py
Log:
use new parser features to show parse and lex errors


Modified: pypy/dist/pypy/lang/prolog/interpreter/main.py
==============================================================================
--- pypy/dist/pypy/lang/prolog/interpreter/main.py	(original)
+++ pypy/dist/pypy/lang/prolog/interpreter/main.py	Mon Nov 13 21:31:04 2006
@@ -77,32 +77,12 @@
             if not source.strip():
                 return None, None
             return get_query_and_vars(source)
-        except ParseError, e:
-            #print e
-            # fake a Python syntax error :-)
-            absoffset = e.args[1][-1]
-            lines = source.split("\n")
-            curroffset = 0
-            for i, line in enumerate(lines):
-                if curroffset <= absoffset < curroffset + len(line) + 1:
-                    break
-                curroffset = curroffset + len(line) + 1
-            if source.strip().endswith("."):
-                raise SyntaxError(
-                    "syntax error",
-                    (filename, i+1, absoffset - curroffset, line))
-            return None
-        except LexerError, e:
-            # fake a Python syntax error
-            absoffset = e.index
-            lines = source.split("\n")
-            curroffset = 0
-            for i, line in enumerate(lines):
-                if curroffset <= absoffset < curroffset + len(line) + 1:
-                    break
-                curroffset = curroffset + len(line) + 1
-            raise SyntaxError(
-                "token error", (filename, i + 1, absoffset - curroffset, line))
+        except ParseError, exc:
+            self.write(exc.nice_error_message("<stdin>", source) + "\n")
+            raise SyntaxError
+        except LexerError, exc:
+            self.write(exc.nice_error_message("<stdin>") + "\n")
+            raise SyntaxError
 
     def runcode(self, code):
         try:



More information about the Pypy-commit mailing list