aboutsummaryrefslogtreecommitdiff
path: root/lib/Lexer/Lexer.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-13 14:52:57 +0000
committer_ov4 <ov4@ov4.org>2026-10-13 14:52:57 +0000
commita484f314b719aec5ed7bdc6f08403342b2125561 (patch)
tree531e331cf823517eae4c350d37bca6a500b2de9f /lib/Lexer/Lexer.cc
parent4297086c86f4d11e8a14b76b50705b419d6b7f13 (diff)
feat(compiler)!: add try-catch with C++ stack unwinding
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>
Diffstat (limited to 'lib/Lexer/Lexer.cc')
-rw-r--r--lib/Lexer/Lexer.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Lexer/Lexer.cc b/lib/Lexer/Lexer.cc
index a71b37c..d366afc 100644
--- a/lib/Lexer/Lexer.cc
+++ b/lib/Lexer/Lexer.cc
@@ -86,6 +86,11 @@ int Lexer::gettok() {
if (IdentifierStr == "ELSE") return tok_else;
if (IdentifierStr == "ENDIF") return tok_endif;
+ if (IdentifierStr == "TRY") return tok_try;
+ if (IdentifierStr == "CATCH") return tok_catch;
+ if (IdentifierStr == "ENDTRY") return tok_endtry;
+ if (IdentifierStr == "THROW") return tok_throw;
+
if (IdentifierStr == "WHILE") return tok_while;
if (IdentifierStr == "DO") return tok_do;
if (IdentifierStr == "ENDWHILE") return tok_endwhile;