diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-22 15:33:17 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-22 15:35:05 +0000 |
| commit | 8745f421b4cf7e1d54c17a360d46fab889ca12cc (patch) | |
| tree | 4c2a3508627db04493af35643580417d41b63f89 /include/cps | |
| parent | 5e84edbe1a79c6a7752ee276ea6c1a4daef4fa8e (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'include/cps')
| -rw-r--r-- | include/cps/CodeGen.h | 8 | ||||
| -rw-r--r-- | include/cps/TypeSystem.h | 1 |
2 files changed, 2 insertions, 7 deletions
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<MemoryHandler> 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<std::unique_ptr<StmtAST>> &Statements, int Phase); diff --git a/include/cps/TypeSystem.h b/include/cps/TypeSystem.h index 0c7c888..91a86c3 100644 --- a/include/cps/TypeSystem.h +++ b/include/cps/TypeSystem.h @@ -77,7 +77,6 @@ struct TypeInfo { std::string CIdentity; unsigned CRank = 0; bool CSigned = false; - std::string CInputFormat; std::string COutputFormat; bool isC() const; |
