changeset 23:eb486f9b7590

Die gracefully Don't explode into a 20 line stack trace if the kll file is formatted incorrectly. Instead simply show the error message and exit with an error code (which will stop the rest of a make command). A misformatted file is most likely a user error so showing the full backtrace for debugging is not necessary. The file and line number should (hopefully) be enough to fix the parsing error.
author Rowan Decker <Smasher816@gmail.com>
date Wed, 31 Dec 2014 01:48:08 -0600
parents 9eff1762e74f
children 092deb852ad9
files kll.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kll.py	Wed Dec 10 22:21:51 2014 -0800
+++ b/kll.py	Wed Dec 31 01:48:08 2014 -0600
@@ -552,9 +552,11 @@
 		data = file.read()
 		tokenSequence = tokenize( data )
 		#print ( pformat( tokenSequence ) ) # Display tokenization
-		tree = parse( tokenSequence )
-
-
+		try:
+			tree = parse( tokenSequence )
+		except NoParseError as e:
+			print("Error parsing %s. %s" % (filename, e.msg), file=sys.stderr)
+			sys.exit(1)
 
 ### Main Entry Point ###