-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
28 lines (22 loc) · 721 Bytes
/
Copy pathutils.js
File metadata and controls
28 lines (22 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let hadError = false;
let hadRuntimeError = false;
export const hasError = () => hadError;
export const clearError = () => hadError = false;
export const hasRuntimeError = () => hadRuntimeError;
export const clearRuntimeError = () => hadRuntimeError = false;
export function error(token = {}, message = 'Error') {
if (token.type == 'EOF') {
report(token.line, ' at end', message);
} else {
report(token.line, ' at "' + token.lexeme + '"', message);
}
hadError = true;
}
export function runtimeError(error) {
console.error(`${error.message}
[line ${error.token.line}]`);
hadRuntimeError = true;
}
export function report(line, where, message) {
console.error(`[line ${line}] Error${where}: ${message}`);
}