aboutsummaryrefslogtreecommitdiff
path: root/lib/Lexer
AgeCommit message (Collapse)Author
2026-10-30feat(types): support implicit single-argument constructors_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28feat(overload): support default return types_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27feat(library)!: replace #LIB with __LIB source regions_ov4
Track library mode by original source line, including deferred template bodies and automatic object cleanup. Update call lines from ordinary code and migrate the embedded standard library to PP_DEFINE __LIB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27feat(preprocessor): add file-local conditional switches_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22fix(parser): name the unexpected token in expression diagnostics_ov4
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-22refactor(lexer): report lexer errors through a single helper_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(lexer): look up keywords in a static table_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22refactor(lexer): drop redundant single-character token branches_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(diagnostics): print source diagnostics in gcc file:line: layout_ov4
Lexer, parser, driver and codegen diagnostics now read "<path>:<line>: error: <message>" instead of "error: <message> at line N in <path>". The path is always printed as given on the command line. Call sites pass the bare message to cps::sourceError/sourceWarning, which carry printf format checking; reportError routes through the same helper. The suite iii harness parses the new layout and matches the reason against the message only. iii/template-class-pack-field passed only because its reason regex matched the case path, so it is now case-insensitive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21feat(parser): parse TEMPLATE declarations, template ids and parameter packs_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20feat(lexer): add C_STRING literal suffix_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(driver): add #LIB directive hiding library lines in runtime errors_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(lexer): accept identifiers starting with an underscore_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(lexer): support C++ escape sequences in literals_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18feat(operators): support global binary operator overloads_ov4
Resolve exact operand types and preserve declared operator return types. Reject implicit STRING to BOOLEAN conversion at typed expression boundaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(parser): parse EXTERN "C" declarations and INCLUDE_OBJ_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(parser): parse OVERLOAD prefix on FUNCTION and PROCEDURE_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(parser): parse INCLUDE and GLOBAL blocks_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17refactor(diag): file-qualified diagnostic locations_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): parse DELETE destructor methods and DELETE statement_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17feat(classes): support explicit NEW constructor method calls_ov4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16fix(compiler): correct CIE semantics and diagnostic locations_ov4
Use standard WHILE headers and default-public class fields, resolve pseudocode identifiers without case sensitivity, and check signed i64 literal boundaries before conversion. Preserve source locations across recursive emission and function diagnostics. Add 22 regression cases and update compiler examples and documentation. Validated all 69 CTest entries with the original Linux Actions seed and verified the release package's embedded, native and IR output paths.
2026-10-16feat(constants): implement literal constants with lexical scope_ov4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-16feat(control-flow): implement ordered CASE OF matching_ov4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-14feat(types): add native C scalar types and imported aliases_ov4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-13feat(compiler)!: add try-catch with C++ stack unwinding_ov4
Add TRY/CATCH/ENDTRY and anonymous THROW statements. Use LLVM exception handling and the C++ ABI to propagate exceptions across function calls, clean up catch state, and handle uncaught exceptions at the program boundary. Register exception runtime symbols for the statically linked embedded runner. Verify runtime checks, nested catches, returns, loops, and invalid syntax with smoke programs; exercise unwinding with MCJIT, lli, and native binaries. BREAKING CHANGE: Runtime check failures now throw anonymous exceptions and print only a generic message when uncaught. Native binaries require linking the C++ runtime. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-13Add record-derived classes with explicit field visibility_ov4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-13fix: distinguish compiler errors and report compilation termination_ov4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-13feat: compile source files with configurable IR output_ov4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-07-26feat: TYPE-system front end — tokens, designators, ParamDecl grammar_ov4
- Reserve TYPE/ENDTYPE/SET/DEFINE (-600 token block); SET/DEFINE parse to dedicated not-implemented errors (RANDOM precedent). - New TypeAST.h: enum/pointer/record decl nodes, designator chain (DesignatorExprAST + Index/Field/Deref accessors), AddrOfExprAST, DesignatorAssignStmtAST. Bare-name and single-index shapes degrade to their legacy nodes, so existing programs produce identical ASTs. - ParserType.cc: TYPE declarations (top-level only, enforced via a ParseBlock depth counter), DECLARE-only record bodies with local field-level error recovery. - Postfix [ ] . ^ chain in ParseIdentifierExpr; prefix ^ (address-of, designator operand only) in ParseUnary; assignment targets rebuilt on the same suffix parser. - Parameters: ParamDecl{name, type, mode, array rank/bounds} replaces the (name, type, byref) tuple. Pass mode is sticky across parameters and BYREF is rejected in FUNCTIONs, both per guide §8.3 (the old per-param reset made the guide's own SWAP example pass Y by value). ARRAY OF T / ARRAY[l:u,...] OF T parameter syntax parses; codegen rejects it until the parameter-passing phase lands. - CodeGen stubs report clear not-implemented errors for the new nodes so nothing is silently ignored. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26feat: implement CIE 9.1 text file handling ↵_ov4
(OPENFILE/READFILE/WRITEFILE/CLOSEFILE/EOF) Front end: OPENFILE/READFILE/WRITEFILE/CLOSEFILE plus reserved mode keywords READ/WRITE/APPEND (RANDOM reserved with a dedicated not-implemented error); statement nodes in new FileAST.h, parsing in new ParserFile.cc; EOF joins the Builtins table as the 12th builtin and CallExprAST now carries a line number for its runtime diagnostics. Runtime: new FileHandler (StringHandler-shaped leaf) lazily synthesizes internal __cps_file_* helper functions and a 16-slot open-file table keyed by filename content (strcmp — STRING '=' is pointer identity). EOF is an fgetc/ungetc peek; READFILE grows a malloc/realloc line buffer and strips a trailing CR; fopen uses text modes so mingw-w64 line translation works. File-free programs get byte-identical IR. All misuse (not open, wrong mode, reopen, fopen failure, read past EOF, table full) dies with the existing "[Fatal] line N:" pattern via a new RuntimeCheck::emitErrorAndExit overload taking runtime printf args. Also fixes a pre-existing ArithmeticHandler hole surfaced by adversarial review: mixed-width integer operands (i1 BOOLEAN / i8 CHAR vs i64) now widen via ZExt instead of emitting invalid IR, and remaining type mismatches get a clean diagnostic; -EOF(f) and -IS_NUM(x) compile. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26refactor: single builtin registry, retire keyword route for builtins_ov4
All 11 builtins now live in one static {Name, Arity, ReturnTypeName} table in CodeGen.cc: emitExpr checks arity against it (uniform "Error: X expects N args" diagnostics) and getExprTypeInfo reads return types from it, removing the duplicated hard-coded table. LENGTH/MID/RIGHT/LEFT/LCASE/UCASE lose their lexer tokens and ParseStringBuiltin; they parse as ordinary identifier calls exactly like ASC/CHR/IS_NUM/NUM_TO_STR/STR_TO_NUM already did. Behavior note: these six names are no longer reserved words. AGENTS docs updated for the new builtin story and the batch-1 error contract (exit codes, verifyModule, fixed descending FOR). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26refactor: batch 1 - correctness and error contract_ov4
- MID/RIGHT/LEFT integer args now coerced at call sites (RIGHT(s, n/2) no longer emits invalid IR); drop emitLeft's private conversion - FOR loop direction decided at run time via select on STEP sign; descending FOR works, STEP evaluated once per iteration - ArrayHandler: extract emitCheckedIndices/loadElement; index count is validated before emission, fixing a compiler-crash (vector OOB UB) on OUTPUT with too many indices - Error contract: Lexer/Parser/CodeGen track errors; all silent failure paths now print Error: diagnostics with line numbers; unterminated char literal no longer truncates the rest of the program; module is verified with verifyModule; driver exits non-zero on any error Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-03-27feat: generalize typed array support_ov4
2026-03-03Added all built-in functions_ov4
2026-02-02Added STRING_ov4
2026-02-02Added logical operators_ov4
2026-02-02Added REAL and BOOLEAN types, DIV and MOD operators_ov4
2026-01-30Added BYREF and BYVAL_ov4
2026-01-30Added FUNCTION and PROCEDURE_ov4
2026-01-30Changed INTEGER from i32 to i64ov-4
2026-01-30Added runtime check for array index and divisionov-4
2026-01-29Added arrayov-4
2026-01-29Added loop statements, FOR, WHILE and REPEATov-4
2026-01-29Added support for comments using //ov-4
2026-01-29Added half way of IF statementov-4
2026-01-29Added INPUT, OUTPUT and DECLAREov-4