feat: add extern fn declarations for JS FFI
Adds `extern fn` syntax for declaring external JavaScript functions: extern fn getElementById(id: String): Element extern fn getContext(el: Element, kind: String): CanvasCtx = "getContext" pub extern fn alert(msg: String): Unit Changes across 11 files: - Lexer: `extern` keyword - AST: `ExternFnDecl` struct + `Declaration::ExternFn` variant - Parser: parse `extern fn` with optional `= "jsName"` override - Typechecker: register extern fn type signatures - Interpreter: ExternFn value with clear error on call - JS backend: emit extern fn calls using JS name (no _lux suffix) - C backend: silently skips extern fns - Formatter, linter, modules, symbol_table: handle new variant Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -403,6 +403,9 @@ impl Linter {
|
||||
Declaration::Function(f) => {
|
||||
self.defined_functions.insert(f.name.name.clone());
|
||||
}
|
||||
Declaration::ExternFn(e) => {
|
||||
self.defined_functions.insert(e.name.name.clone());
|
||||
}
|
||||
Declaration::Let(l) => {
|
||||
self.define_var(&l.name.name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user