2012-05-07 03:06:28 +00:00
|
|
|
"""Error logging
|
|
|
|
|
|
|
|
Keeps track of the number of errors inflicted so far, and
|
|
|
|
where in the assembly the errors are occurring."""
|
|
|
|
|
2014-03-23 05:09:11 +00:00
|
|
|
# Copyright 2002-2014 Michael C. Martin and additional contributors.
|
2012-05-07 03:06:28 +00:00
|
|
|
# You may use, modify, and distribute this file under the MIT
|
|
|
|
# license: See README for details.
|
|
|
|
|
2012-05-29 02:19:08 +00:00
|
|
|
import sys
|
|
|
|
|
2012-05-07 03:06:28 +00:00
|
|
|
count = 0
|
|
|
|
currentpoint = "<Top Level>"
|
|
|
|
|
2012-06-01 17:25:48 +00:00
|
|
|
|
2012-05-07 03:06:28 +00:00
|
|
|
def log(err):
|
|
|
|
"""Reports an error at the current program point, and increases
|
|
|
|
the global error count."""
|
|
|
|
global count
|
2012-06-01 17:25:48 +00:00
|
|
|
count = count + 1
|
2019-01-10 04:45:01 +00:00
|
|
|
print(currentpoint + ": " + err, file=sys.stderr)
|
2012-06-01 17:25:48 +00:00
|
|
|
|
2012-05-07 03:06:28 +00:00
|
|
|
|
|
|
|
def report():
|
|
|
|
"Print out the number of errors."
|
2012-06-01 17:25:48 +00:00
|
|
|
if count == 0:
|
2019-01-10 04:45:01 +00:00
|
|
|
print("No errors", file=sys.stderr)
|
2012-06-01 17:25:48 +00:00
|
|
|
elif count == 1:
|
2019-01-10 04:45:01 +00:00
|
|
|
print("1 error", file=sys.stderr)
|
2012-06-01 17:25:48 +00:00
|
|
|
else:
|
2019-01-10 04:45:01 +00:00
|
|
|
print(str(count) + " errors", file=sys.stderr)
|