diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 05:09:23 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 05:09:23 +0000 |
| commit | f282535399a0c5cae8f6965bb32f449f834c0757 (patch) | |
| tree | b37b6024fd94b922a82d6b7938d3a671f877fddb | |
| parent | a6b8afcfb61e1d321405fe8713beaec2aa6320a2 (diff) | |
docs(input): document array and member targets
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
| -rw-r--r-- | AGENTS/PITFALLS.md | 12 | ||||
| -rw-r--r-- | doc/language/cpsc-language-overview.7.md | 2 | ||||
| -rw-r--r-- | doc/language/keyword/cpsc-keyword-input.7.md | 29 | ||||
| -rw-r--r-- | tests/FAILURES.md | 4 |
4 files changed, 34 insertions, 13 deletions
diff --git a/AGENTS/PITFALLS.md b/AGENTS/PITFALLS.md index dacf106..d604504 100644 --- a/AGENTS/PITFALLS.md +++ b/AGENTS/PITFALLS.md @@ -8,8 +8,10 @@ test programs. - **OUTPUT accepts comma-separated expressions (§5.1).** Values are evaluated and printed left to right without automatic separators; the final scalar adds a newline. Whole arrays and subarrays still print each element on its own line, including in - mixed output lists; a final array adds no extra newline. INPUT only accepts a plain - identifier — no `INPUT arr[i]`. + mixed output lists; a final array adds no extra newline. INPUT accepts writable + scalar locations, including array elements, public record/class fields and + pointer dereferences, using the shared lvalue checks. Whole arrays and whole + records/classes remain unsupported INPUT targets. - **Arrays cross function boundaries only as parameters.** `ArrayTable` is scoped per function now, so referencing another function's array fails cleanly as "Undeclared array". Whole arrays pass as `ARRAY OF T` / `ARRAY[l:u,...] OF T` @@ -49,8 +51,8 @@ test programs. - **File handling (§9.1) sharp edges.** `READ`/`WRITE`/`APPEND`/`RANDOM` are reserved keywords now — `DECLARE READ : INTEGER` no longer compiles. `WRITEFILE f, a, b` takes exactly two operands (the stray `, b` is a parse error). - READFILE's target must be a plain STRING variable — no CHAR, no `arr[i]` (mirrors - INPUT). The CIE guide's empty-line test `IF LineOfText = ""` compares contents. + READFILE's target must be a plain STRING variable — no CHAR, no `arr[i]`. + The CIE guide's empty-line test `IF LineOfText = ""` compares contents. At most 16 files open at once. All runtime misuse (not open, wrong mode, reopen, fopen failure, READFILE past EOF) throws an anonymous exception — guard reads with `WHILE NOT EOF(...)`. Caveat: the open-file table is keyed by the filename *string* @@ -106,7 +108,7 @@ test programs. SET types (`SET`/`DEFINE` are reserved with dedicated errors), random files (OPENFILE...FOR RANDOM/SEEK/GETRECORD/PUTRECORD — TYPE is done, so these are unblocked now; the RANDOM keyword is reserved and gives a dedicated parse error), -DATE, INPUT into array elements, string escape sequences, +DATE, string escape sequences, array-typed record fields, whole-array RETURN, class methods/constructors/destructors, NEW and class inheritance. Compiler fixtures now live in `tests/` (see TESTING.md). Nightly CI runs the compiler suites, packaged EMBEDDED smoke checks and existing diff --git a/doc/language/cpsc-language-overview.7.md b/doc/language/cpsc-language-overview.7.md index 233e9ef..8838b7f 100644 --- a/doc/language/cpsc-language-overview.7.md +++ b/doc/language/cpsc-language-overview.7.md @@ -67,7 +67,7 @@ Closing and auxiliary keywords are documented with their main constructs: THEN/E # UNSUPPORTED FEATURES -DATE, SET types and DEFINE, random-file operations (RANDOM/SEEK/GETRECORD/PUTRECORD), INT, RAND, INPUT into array elements or fields, string escapes, whole-array assignment or return, array fields, and class methods/constructors/destructors/inheritance (NEW/INHERITS/SUPER). +DATE, SET types and DEFINE, random-file operations (RANDOM/SEEK/GETRECORD/PUTRECORD), INT, RAND, string escapes, whole-array assignment or return, array fields, and class methods/constructors/destructors/inheritance (NEW/INHERITS/SUPER). The individual pages note relevant differences from the Cambridge 2026 pseudocode guide. This manual describes the compiler's current support. diff --git a/doc/language/keyword/cpsc-keyword-input.7.md b/doc/language/keyword/cpsc-keyword-input.7.md index c1ec905..4c6c309 100644 --- a/doc/language/keyword/cpsc-keyword-input.7.md +++ b/doc/language/keyword/cpsc-keyword-input.7.md @@ -7,21 +7,38 @@ cpsc-keyword-input - read a value from standard input # SYNOPSIS ```text -INPUT variable +INPUT target ``` # DESCRIPTION -Read into a previously declared INTEGER, REAL, BOOLEAN, CHAR, or STRING variable. STRING input reads one whitespace-delimited word. The target must be a plain variable; array elements and record/class fields are unsupported, unlike the wider INPUT syntax in guide section 5.1. +Read into an INTEGER, REAL, BOOLEAN, CHAR, or STRING location: a previously declared variable, an individual array element, or a public record/class field, as allowed by guide section 5.1. Nested fields, fields of array elements and pointer dereferences are supported through the existing access syntax. STRING input reads one whitespace-delimited word. -Native C scalar variables are also supported, using their actual widths and signedness. Plain C char reads a character; signed/unsigned char read numbers. C _Bool reads a number and stores whether it is nonzero. C pointers, including C_STRING, cannot be INPUT targets. See [cpsc-keyword-c_type(7)](cpsc-keyword-c_type.7.md). +Native C scalar targets are also supported, using their actual widths and signedness. Plain C char reads a character; signed/unsigned char read numbers. C _Bool reads a number and stores whether it is nonzero. C pointers, including C_STRING, cannot be INPUT targets. See [cpsc-keyword-c_type(7)](cpsc-keyword-c_type.7.md). + +The target address is evaluated once per INPUT execution, before reading the value. Array bounds, unset pointers and private fields are checked as for assignment. Constants, whole arrays, whole records/classes, enums and pointer values cannot be INPUT targets. A dereferenced pointer may select a supported target type. # EXAMPLE ```text -DECLARE Name : STRING -INPUT Name -OUTPUT Name +DECLARE Scores : ARRAY[1:3] OF INTEGER +DECLARE j : INTEGER +FOR j <- 1 TO 3 + INPUT Scores[j] +NEXT j +OUTPUT Scores + +TYPE Student + DECLARE Score : INTEGER +ENDTYPE +CLASS Box + Value : INTEGER +ENDCLASS +DECLARE Person : Student +DECLARE Item : Box +INPUT Person.Score +INPUT Item.Value +OUTPUT Person.Score, ":", Item.Value ``` # SEE ALSO diff --git a/tests/FAILURES.md b/tests/FAILURES.md index d88b850..dca0b8a 100644 --- a/tests/FAILURES.md +++ b/tests/FAILURES.md @@ -26,9 +26,11 @@ At baseline, both native and `-r` paths exposed the four i-group failures. All n Current exact command results are retained in `build/test-results`; the replay uses the original Actions SHA as its seed. Subsequent CI reports use their own explicit push SHA. Platform results from Actions are the authority for Windows/macOS verification; local Linux results do not establish their behavior. +The `i/input-targets` and `iii/input-invalid-targets` cases cover INPUT into array elements and public record/class fields, including nested fields and pointer dereferences, with existing writable-location and type restrictions. + ## Coverage gaps -- Not implemented by the compiler, and not required to pass this initial suite: DATE, SET/DEFINE, random files, class methods/constructors/inheritance, INT/RAND, whole-array assignment and INPUT into array/record elements. Rejection of valid CIE syntax must not be relabeled as a successful negative test. +- Not implemented by the compiler, and not required to pass this initial suite: DATE, SET/DEFINE, random files, class methods/constructors/inheritance, INT/RAND and whole-array assignment. Rejection of valid CIE syntax must not be relabeled as a successful negative test. - The guide's p. 14 pointer example points an INTEGER pointer at an enum; it conflicts with the project's explicit strict-pointee contract. Tests use matching pointees rather than silently choosing a new policy. - LCASE/UCASE are CHAR-to-CHAR in the guide (p. 17), while the project declares STRING results and also supports whole strings. Output observations cover case conversion but do not prove exact static return-type conformance. - No requirements are invented for unspecified integer overflow, REAL output spelling, out-of-range substring behavior, Unicode character semantics, or uninitialized CIE values. Native C ABI behavior is checked only against that platform's independent C++ reference. |
