From 8745f421b4cf7e1d54c17a360d46fab889ca12cc Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 15:33:17 +0000 Subject: feat(input)!: validate INPUT and read whole lines into STRING Scalar INPUT now reads one whitespace-delimited token through module-local IR helpers instead of scanf, then skips spaces and tabs and consumes one newline. INTEGER, REAL, BOOLEAN (TRUE or FALSE in any case) and CHAR are validated, and bad input or end of input is a runtime error. STRING INPUT reads the rest of the line. The unused scanf and REAL printf format globals are removed. Co-Authored-By: Claude Sonnet 5.5 --- include/cps/CodeGen.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'include/cps/CodeGen.h') diff --git a/include/cps/CodeGen.h b/include/cps/CodeGen.h index 9985f9b..ffd589c 100644 --- a/include/cps/CodeGen.h +++ b/include/cps/CodeGen.h @@ -151,16 +151,11 @@ class CodeGen { std::unique_ptr Memory; llvm::FunctionCallee PrintfFunc; - llvm::FunctionCallee ScanfFunc; llvm::Value *PrintfFormatStr; // %lld\n - llvm::Value *PrintfFloatFormatStr; // %f\n llvm::Value *PrintfStringFormatStr; // %s\n llvm::Value *PrintfCharFormatStr; // %c\n - llvm::Value *ScanfFormatStr; // %lld - llvm::Value *ScanfFloatFormatStr; // %lf - llvm::Value *TrueStr; // "TRUE" llvm::Value *FalseStr; // "FALSE" llvm::Value *EmptyStringStr; // "" @@ -184,7 +179,8 @@ class CodeGen { llvm::Value *emitCBinaryOp(int Op, llvm::Value *L, const TypeInfo *Left, llvm::Value *R, const TypeInfo *Right, int Line); void emitCOutput(llvm::Value *Val, const TypeInfo *Info, bool AppendNewline); - void emitCInput(llvm::Value *Addr, const TypeInfo *Info); + void emitCInput(llvm::Value *Addr, const TypeInfo *Info, int Line); + void emitScalarInput(llvm::Value *Addr, const TypeInfo *Info, int Line); // TYPE-system registration (Designator.cc) and operators (TypeCheckGen.cc). void runTypePrePass(const std::vector> &Statements, int Phase); -- cgit v1.3.1-4-g156e