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

cfbolz at codespeak.net cfbolz at codespeak.net
Sun Nov 12 23:43:59 CET 2006


Author: cfbolz
Date: Sun Nov 12 23:43:58 2006
New Revision: 34543

Modified:
   pypy/dist/pypy/lang/prolog/interpreter/translatedmain.py
Log:
better error reporting for in case of parse errors


Modified: pypy/dist/pypy/lang/prolog/interpreter/translatedmain.py
==============================================================================
--- pypy/dist/pypy/lang/prolog/interpreter/translatedmain.py	(original)
+++ pypy/dist/pypy/lang/prolog/interpreter/translatedmain.py	Sun Nov 12 23:43:58 2006
@@ -121,7 +121,7 @@
     else:
         printmessage("yes\n")
 
-def repl(e):
+def repl(engine):
     printmessage("welcome!\n")
     while 1:
         printmessage(">?- ")
@@ -129,12 +129,15 @@
         if line == "halt.\n":
             break
         try:
-            goals, var_to_pos = e.parse(line)
-        except ParseError:
-            printmessage("parse error\n")
+            goals, var_to_pos = engine.parse(line)
+        except ParseError, exc:
+            printmessage(exc.nice_error_message("<stdin>", line) + "\n")
+            continue
+        except LexerError, exc:
+            printmessage(exc.nice_error_message("<stdin>") + "\n")
             continue
         for goal in goals:
-            run(goal, var_to_pos, e)
+            run(goal, var_to_pos, engine)
  
 def execute(e, filename):
     e.run(term.Term("consult", [term.Atom(filename)]))



More information about the Pypy-commit mailing list