-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.odin
More file actions
79 lines (67 loc) · 2.3 KB
/
Copy patherrors.odin
File metadata and controls
79 lines (67 loc) · 2.3 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package hephaistos
import "core:fmt"
error_parser_start_end :: proc(parser: ^Parser, start, end: Location, format: string, args: ..any) {
append(&parser.errors, Error {
location = start,
end = end,
message = fmt.aprintf(format, ..args, allocator = parser.error_allocator),
})
}
error_parser_single_token :: proc(parser: ^Parser, token: Token, format: string, args: ..any) {
append(&parser.errors, Error {
location = token.location,
end = {
line = token.location.line,
column = token.location.column + i32(len(token.text)),
offset = token.location.offset + i32(len(token.text)),
},
message = fmt.aprintf(format, ..args, allocator = parser.error_allocator),
})
}
error_checker_operand :: proc(checker: ^Checker, operand: Operand, message: string, args: ..any) {
append(&checker.errors, Error {
location = operand.expr.start,
end = operand.expr.end,
message = fmt.aprintf(message, ..args, allocator = checker.error_allocator),
})
}
error_checker_location :: proc(checker: ^Checker, location: Location, message: string, args: ..any) {
append(&checker.errors, Error {
location = location,
end = location,
message = fmt.aprintf(message, ..args, allocator = checker.error_allocator),
})
}
error_checker_start_end :: proc(checker: ^Checker, start, end: Location, message: string, args: ..any) {
append(&checker.errors, Error {
location = start,
end = end,
message = fmt.aprintf(message, ..args, allocator = checker.error_allocator),
})
}
error_checker_token :: proc(checker: ^Checker, token: Token, message: string, args: ..any) {
end := token.location
end.offset += i32(len(token.text))
end.column += i32(len(token.text))
append(&checker.errors, Error {
location = token.location,
end = end,
message = fmt.aprintf(message, ..args, allocator = checker.error_allocator),
})
}
error_checker_ast_node :: proc(checker: ^Checker, ast_node: ^Ast_Node, message: string, args: ..any) {
append(&checker.errors, Error {
location = ast_node.start,
end = ast_node.end,
message = fmt.aprintf(message, ..args, allocator = checker.error_allocator),
})
}
error :: proc {
error_parser_start_end,
error_parser_single_token,
error_checker_operand,
error_checker_location,
error_checker_token,
error_checker_ast_node,
error_checker_start_end,
}