From f282535399a0c5cae8f6965bb32f449f834c0757 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 05:09:23 +0000 Subject: docs(input): document array and member targets Co-Authored-By: Claude Fable 5.1 --- doc/language/cpsc-language-overview.7.md | 2 +- doc/language/keyword/cpsc-keyword-input.7.md | 29 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'doc') 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 -- cgit v1.3.1-4-g156e