diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-21 14:03:31 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-21 14:03:31 +0000 |
| commit | b4ffb2d9498560557821714e2d4651279dd6817c (patch) | |
| tree | 995ad02bdb8cc461f48a53683c4fd7f2ddd8656b /AGENTS | |
| parent | f1f5fa394a67a789914ccf2b24d534a0e466ae1b (diff) | |
feat(diagnostics): print source diagnostics in gcc file:line: layout
Lexer, parser, driver and codegen diagnostics now read
"<path>:<line>: error: <message>" instead of "error: <message> at line N
in <path>". The path is always printed as given on the command line.
Call sites pass the bare message to cps::sourceError/sourceWarning, which
carry printf format checking; reportError routes through the same helper.
The suite iii harness parses the new layout and matches the reason
against the message only. iii/template-class-pack-field passed only
because its reason regex matched the case path, so it is now
case-insensitive.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'AGENTS')
| -rw-r--r-- | AGENTS/ARCH/DRIVER.md | 5 | ||||
| -rw-r--r-- | AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md | 9 | ||||
| -rw-r--r-- | AGENTS/TESTING.md | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/AGENTS/ARCH/DRIVER.md b/AGENTS/ARCH/DRIVER.md index af3925a..d571509 100644 --- a/AGENTS/ARCH/DRIVER.md +++ b/AGENTS/ARCH/DRIVER.md @@ -34,8 +34,9 @@ style is in [CONVENTIONS/SYMBOLS_AND_ERRORS.md](../CONVENTIONS/SYMBOLS_AND_ERROR also return 1. Ordinary compiler errors use `error:`; failures that prevent compilation, such as file I/O errors, use `fatal error:`. The driver prints `compilation terminated.` once on compilation failure, including argument errors. - Multi-input lexer/parser/codegen diagnostics append the source path after the line number; - single-input diagnostics (Diagnostics.h) do not append it. + Lexer/parser/codegen diagnostics use the gcc layout `<path>:<line>: error: <message>` + (Diagnostics.h), with the path as given on the command line; driver-level errors + use `cpsc: error:` / `cpsc: fatal error:`. Execution-stage failures do not print that line. Check the exit code rather than grepping stderr. - Successful compilation overwrites the output, but paths aliasing any input source diff --git a/AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md b/AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md index 3e3c3ad..e21bed1 100644 --- a/AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md +++ b/AGENTS/CONVENTIONS/SYMBOLS_AND_ERRORS.md @@ -42,8 +42,13 @@ keep compiling.** No exceptions, no exit mid-compile. - `Lexer`/`Parser`/`CodeGen` each expose `hadError()`; AST expressions/statements share source-line metadata. Parser entry points record token locations. CodeGen - saves/restores its diagnostic line across recursive emission and coercion; - `reportError` appends `at line N`. + saves/restores its diagnostic line across recursive emission and coercion. +- Diagnostics use the gcc layout `<path>:<line>: error: <message>` (`<path>:` when + the line is unknown). Lexer/parser/driver call `cps::sourceError(Line, fmt, ...)` + (`sourceWarning` for warnings) from `Diagnostics.h` with the bare message: no + `error:` label, location or newline. `reportError` routes through the same helper + with `DiagnosticLine`. `DiagnosticSource` holds the unit path as given on the + command line. - `CodeGen::reportError(fmt, ...)` is the helper for codegen-side diagnostics (`ArrayHandler` reaches it through its `CodeGen &` parameter, `FunctionGen`/`ArithmeticHandler` hold a `bool &HadError` reference). diff --git a/AGENTS/TESTING.md b/AGENTS/TESTING.md index a43d0fb..f3628d2 100644 --- a/AGENTS/TESTING.md +++ b/AGENTS/TESTING.md @@ -2,7 +2,7 @@ Compiler tests live in `tests/`; run instructions are in its README. `BUILD_TESTING` defaults to OFF and uses the compiler build's Perl interpreter with core modules when enabled. CMake builds independent C++ reference executables with the same host ABI and registers one CTest entry per `case.json`, plus harness and generator checks. -Each case directory has `program.cps` and `case.json`. Suite i adds `expected.txt`, optional `input.txt`, input files under `files/`, expected text-file contents under `expected-files/`, and independently written trace notes with human-review status. Suite ii adds `reference.cc` and `generate.pl`; the generator accepts seed and random count, emits the total record count followed by one ASCII record per line, and each program emits one result line per record. Suite iii stores an `errors` list of `{reason: regex, line: integer}` in its manifest. A cause and its line must appear on the same error diagnostic. EOF after a final newline is the following source line. +Each case directory has `program.cps` and `case.json`. Suite i adds `expected.txt`, optional `input.txt`, input files under `files/`, expected text-file contents under `expected-files/`, and independently written trace notes with human-review status. Suite ii adds `reference.cc` and `generate.pl`; the generator accepts seed and random count, emits the total record count followed by one ASCII record per line, and each program emits one result line per record. Suite iii stores an `errors` list of `{reason: regex, line: integer}` in its manifest. A cause and its line must appear on the same `<path>:<line>: error: <message>` diagnostic; the reason is matched against the message. EOF after a final newline is the following source line. Multi-file cases specify `sources` as an ordered array of paths relative to the case directory, defaulting to `["program.cps"]`. Library sources can be in nested |
