Conditions | 2 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 16 |
Ratio | 100 % |
Tests | 1 |
CRAP Score | 4.8094 |
Changes | 0 |
1 | # ---------------------------------------------------------------------------------------------------------------------- |
||
38 | 1 | def _error(self, message: str, token: Optional[CommonToken] = None) -> None: |
|
39 | """ |
||
40 | Logs an error. |
||
41 | |||
42 | :param str message: The error message.This message will be appended with 'at filename:line.column' ot the token. |
||
43 | :param antlr4.Token.CommonToken token: The token where the error occurred. |
||
44 | """ |
||
45 | self._errors += 1 |
||
46 | |||
47 | filename = token.getInputStream().fileName # Replace fileName with get_source_name() when implemented in ANTLR. |
||
48 | line_number = token.line |
||
49 | column_number = token.column + 1 |
||
50 | messages = [message] |
||
51 | if token: |
||
52 | messages.append('Position: {0!s}:{1:d}.{2:d}'.format(filename, line_number, column_number)) |
||
53 | self._io.write_error(messages) |
||
54 | |||
56 |