aboutsummaryrefslogtreecommitdiff
path: root/doc/cpsc.1.md
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-13 14:57:17 +0000
committer_ov4 <ov4@ov4.org>2026-10-13 14:57:17 +0000
commit0e83581ed907aee1f6e59524c7d28b6f9c016f8e (patch)
treee7d12834f24e2db53953eff552ff3a1e0e5c23c9 /doc/cpsc.1.md
parenta484f314b719aec5ed7bdc6f08403342b2125561 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'doc/cpsc.1.md')
-rw-r--r--doc/cpsc.1.md12
1 files changed, 12 insertions, 0 deletions
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.