1.1 --- a/lplc Mon Jan 09 19:11:31 2017 +0100
1.2 +++ b/lplc Mon Jan 09 19:11:44 2017 +0100
1.3 @@ -3,6 +3,7 @@
1.4 from errors import *
1.5 from os import rename
1.6 from os.path import abspath, exists, join, split
1.7 +from pyparser import error
1.8 from subprocess import Popen, PIPE
1.9 from time import time
1.10 import importer, deducer, optimiser, generator, translator
1.11 @@ -26,6 +27,12 @@
1.12 for module_name, name in missing:
1.13 print >>sys.stderr, "Module %s references an unknown object: %s" % (module_name, name)
1.14
1.15 +def show_syntax_error(exc):
1.16 + print >>sys.stderr, "Syntax error at column %d on line %d in file %s:" % (exc.offset, exc.lineno, exc.filename)
1.17 + print >>sys.stderr
1.18 + print >>sys.stderr, exc.text.rstrip()
1.19 + print >>sys.stderr, " " * exc.offset + "^"
1.20 +
1.21 def stopwatch(activity, now):
1.22 print >>sys.stderr, "%s took %.2f seconds" % (activity, time() - now)
1.23 return time()
1.24 @@ -151,6 +158,12 @@
1.25
1.26 # Report any errors.
1.27
1.28 + except error.SyntaxError, exc:
1.29 + show_syntax_error(exc)
1.30 + if "-tb" in args:
1.31 + raise
1.32 + sys.exit(1)
1.33 +
1.34 except ProcessingError, exc:
1.35 print exc
1.36 if "-tb" in args: