From 0e83581ed907aee1f6e59524c7d28b6f9c016f8e Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 13 Oct 2026 14:57:17 +0000 Subject: docs(language): document exception handling and runtime behavior Add the TRY manual for CATCH, ENDTRY, and anonymous THROW. Update runtime error descriptions, language links, and native linking examples; document catch cleanup and embedded runtime integration in the architecture notes. Verify manual generation, rendered output, relative links, and the TRY example. Record Linux LLVM 18 validation and unverified Windows/macOS support. Co-Authored-By: Claude Fable 5.1 --- doc/cpsc.1.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'doc/cpsc.1.md') diff --git a/doc/cpsc.1.md b/doc/cpsc.1.md index 228fd66..b6b7ad0 100644 --- a/doc/cpsc.1.md +++ b/doc/cpsc.1.md @@ -66,6 +66,14 @@ Save IR and run it: cpsc test.cps -r -o result.ir ``` +Build a native program with a C++ linker so the exception runtime is linked: + +```sh +cpsc test.cps -o test.ll +clang++-18 test.ll -o test +./test +``` + # EXIT STATUS **0** @@ -76,12 +84,16 @@ cpsc test.cps -r -o result.ir With **-r**, return the executed program's exit status. In PATH mode, failure to launch `lli` or a child-process crash returns 1. +An uncaught program exception returns 1 after printing `Unhandled exception. Program terminated.` to standard output. Runtime check failures are exceptions and can be handled with TRY/CATCH/ENDTRY. + # NOTES Compiler diagnostics go to stderr. Failed compilation does not write IR. Successful compilation overwrites an existing output file, but an output path that refers to the source file (including a symbolic or hard link) is rejected. Missing input, including invoking `cpsc` without arguments, reports `cpsc: fatal error: no input files`. Ordinary lexical, syntax and semantic errors use `error:`; failures that prevent compilation, such as file I/O errors, use `fatal error:`. Compilation and argument failures end with one `compilation terminated.` line. Execution-stage failures do not print that line. +Generated IR uses the C++ exception ABI. Native binaries need the C++ runtime; EMBEDDED includes it, while PATH uses the runtime available to `lli`. Exception execution is verified on Linux with LLVM 18; Windows and macOS remain unverified. + # SEE ALSO [cpsc-language-overview(7)](language/cpsc-language-overview.7.md) describes supported syntax and links to the keyword and built-in function manuals. -- cgit v1.3.1-4-g156e