diff options
| author | 2022-08-12 11:20:43 +0200 | |
|---|---|---|
| committer | 2022-08-12 11:20:43 +0200 | |
| commit | eff929f0d323559f3b2e9272e3c1d4aa82fc5c80 (patch) | |
| tree | c3dd54fe4ed4a3082f455c8fe37436f767760977 /src/util.cff | |
| parent | 19f1093f0929b989a06cdee2e7d175e6db15559c (diff) | |
va list, cont fix
Diffstat (limited to 'src/util.cff')
| -rw-r--r-- | src/util.cff | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util.cff b/src/util.cff index 33bce84..c3a08cb 100644 --- a/src/util.cff +++ b/src/util.cff @@ -47,3 +47,21 @@ extern fn addfilepath(s *const u8) int { filepaths[i] = s; return i; } + +fn fileid2path(id int) *const u8 { + assert(id >= 0 and id < filepaths.#len, "fileid"); + let s = filepaths[id]; + assert(s != #null, "fileid"); + return s; +} + +extern fn fatal(P *Parser, loc Loc, fmt *const u8, ...) void { + let ap va_list #?; + ap->start(fmt); + + efmt("%s:%i:%i: error: ", fileid2path(loc.fileid), loc.line, loc.col); + vefmt(fmt, ap); + efmt("\n"); + ap->end(); + exit(1); +} |