- # Number of errors
- readable var _error_count: Int = 0
-
- # Number of warnings
- readable var _warning_count: Int = 0
-
- # Directory where to generate log files
- readable var _log_directory: String = "logs"
-
- # Messages
- var _messages: Array[Message] = new Array[Message]
- var _message_sorter: ComparableSorter[Message] = new ComparableSorter[Message]
-
- fun check_errors
- do
- if _messages.length > 0 then
- _message_sorter.sort(_messages)
-
- for m in _messages do
- stderr.write("{m}\n")
- end
-
- _messages.clear
- end
-
- if error_count > 0 then exit(1)
- end
-
- # Display an error
- fun error(l: nullable Location, s: String)
- do
- _messages.add(new Message(l,s))
- _error_count = _error_count + 1
- if opt_stop_on_first_error.value then check_errors
- end
-
- # Add an error, show errors and quit
- fun fatal_error(l: nullable Location, s: String)
- do
- error(l,s)
- check_errors
- end
-
- # Display a warning
- fun warning(l: nullable Location, s: String)
- do
- if _opt_warn.value == 0 then return
- _messages.add(new Message(l,s))
- if _opt_warn.value == 1 then
- _warning_count = _warning_count + 1
- else
- _error_count = _error_count + 1
- end
- if opt_stop_on_first_error.value then check_errors
- end
-
- # Display an info
- fun info(s: String, level: Int)
- do
- if level <= verbose_level then
- print "{s}"
- end
- end