aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-18 08:04:15 +0000
committer_ov4 <ov4@ov4.org>2026-10-18 08:04:15 +0000
commit927e3fc0384c941f9ad313a28768660c3cdb1777 (patch)
treeee82bef8d8332dad79d05db87f33979f0e7eb423 /doc
parent34a4998658674411ef3b5a392483990467a5d6e2 (diff)
feat(driver): add #LIB directive hiding library lines in runtime errors
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/language/cpsc-language-overview.7.md2
-rw-r--r--doc/language/keyword/cpsc-keyword-lib.7.md31
2 files changed, 33 insertions, 0 deletions
diff --git a/doc/language/cpsc-language-overview.7.md b/doc/language/cpsc-language-overview.7.md
index 96fb071..f04e044 100644
--- a/doc/language/cpsc-language-overview.7.md
+++ b/doc/language/cpsc-language-overview.7.md
@@ -24,6 +24,8 @@ The compiler extensions TRY/CATCH/ENDTRY and THROW support anonymous exceptions
Multi-file builds use the compiler extensions INCLUDE and GLOBAL. Pass every source file on the command line and include the files whose definitions are needed. The entry file contains the sole top-level executable code, or a parameterless FUNCTION MAIN returning INTEGER; definitions alone do not form a runnable program.
+#LIB marks a library source unit. A line-leading `#` starts a compiler directive, not a comment; unknown directives are errors. Library runtime diagnostics report the first user call site. See [cpsc-keyword-lib(7)](keyword/cpsc-keyword-lib.7.md).
+
# KEYWORDS
- [cpsc-keyword-include(7)](keyword/cpsc-keyword-include.7.md): import definitions from another compilation unit.
diff --git a/doc/language/keyword/cpsc-keyword-lib.7.md b/doc/language/keyword/cpsc-keyword-lib.7.md
new file mode 100644
index 0000000..46af0a4
--- /dev/null
+++ b/doc/language/keyword/cpsc-keyword-lib.7.md
@@ -0,0 +1,31 @@
+% CPSC-KEYWORD-LIB(7)
+
+# NAME
+
+cpsc-keyword-lib - mark a library compilation unit
+
+# SYNOPSIS
+
+```text
+#LIB
+```
+
+# DESCRIPTION
+
+A line-leading `#` (optionally preceded by whitespace) begins a compiler directive. Only `#LIB` is supported. It marks the entire source file as library code. Compile-time diagnostics retain library locations; runtime checks use the line of the first call from user code into library code, including methods, operators, automatic constructors/destructors and EXTERN calls. Library-to-library calls preserve that line. Directives are not comments.
+
+C++ library objects may read `extern "C" int __cps_user_line`, print `[Fatal] line N: reason` to stderr and throw an anonymous integer exception for pseudocode TRY/CATCH. The global is shared by the program and is not thread-local.
+
+# EXAMPLE
+
+```text
+#LIB
+PROCEDURE Check()
+ DECLARE A : ARRAY[1:1] OF INTEGER
+ OUTPUT A[2]
+ENDPROCEDURE
+```
+
+# SEE ALSO
+
+[cpsc-keyword-include(7)](cpsc-keyword-include.7.md), [cpsc-keyword-try(7)](cpsc-keyword-try.7.md).