diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 893b7f56..137a3dff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,10 +68,10 @@ jobs: exit 1 fi - - name: Build tree-sitter TypeScript objects + - name: Build tree-sitter TSX objects run: | mkdir -p build - TS_SRC=node_modules/tree-sitter-typescript/typescript/src + TS_SRC=node_modules/tree-sitter-typescript/tsx/src TS_INCLUDE=node_modules/tree-sitter-typescript clang -c -O2 -fPIC -I $TS_SRC -I $TS_INCLUDE $TS_SRC/parser.c -o build/tree-sitter-typescript-parser.o clang -c -O2 -fPIC -I $TS_SRC -I $TS_INCLUDE $TS_SRC/scanner.c -o build/tree-sitter-typescript-scanner.o @@ -158,10 +158,10 @@ jobs: exit 1 fi - - name: Build tree-sitter TypeScript objects + - name: Build tree-sitter TSX objects run: | mkdir -p build - TS_SRC=node_modules/tree-sitter-typescript/typescript/src + TS_SRC=node_modules/tree-sitter-typescript/tsx/src TS_INCLUDE=node_modules/tree-sitter-typescript clang -c -O2 -fPIC -I $TS_SRC -I $TS_INCLUDE $TS_SRC/parser.c -o build/tree-sitter-typescript-parser.o clang -c -O2 -fPIC -I $TS_SRC -I $TS_INCLUDE $TS_SRC/scanner.c -o build/tree-sitter-typescript-scanner.o diff --git a/.github/workflows/cross-compile.yml b/.github/workflows/cross-compile.yml index f47e9604..3c56ca52 100644 --- a/.github/workflows/cross-compile.yml +++ b/.github/workflows/cross-compile.yml @@ -37,7 +37,7 @@ jobs: - name: Build tree-sitter objects run: | mkdir -p build - TS_SRC=node_modules/tree-sitter-typescript/typescript/src + TS_SRC=node_modules/tree-sitter-typescript/tsx/src TS_INCLUDE=node_modules/tree-sitter-typescript clang -c -O2 -fPIC -I $TS_SRC -I $TS_INCLUDE $TS_SRC/parser.c -o build/tree-sitter-typescript-parser.o clang -c -O2 -fPIC -I $TS_SRC -I $TS_INCLUDE $TS_SRC/scanner.c -o build/tree-sitter-typescript-scanner.o diff --git a/c_bridges/treesitter-bridge.c b/c_bridges/treesitter-bridge.c index 744db4dc..61b8cbae 100644 --- a/c_bridges/treesitter-bridge.c +++ b/c_bridges/treesitter-bridge.c @@ -3,13 +3,13 @@ #include #include -extern TSLanguage *tree_sitter_typescript(void); +extern TSLanguage *tree_sitter_tsx(void); extern void *GC_malloc_uncollectable(size_t size); extern void *GC_malloc_atomic(size_t size); TSTree *__ts_parse_source(const char *source, uint32_t length) { TSParser *parser = ts_parser_new(); - TSLanguage *lang = tree_sitter_typescript(); + TSLanguage *lang = tree_sitter_tsx(); ts_parser_set_language(parser, lang); return ts_parser_parse_string(parser, NULL, source, length); } diff --git a/docs/getting-started/cli.md b/docs/getting-started/cli.md index f77ff37a..c3077a16 100644 --- a/docs/getting-started/cli.md +++ b/docs/getting-started/cli.md @@ -87,6 +87,7 @@ SDKs are installed to `~/.chadscript/targets//`. | `--emit-llvm`, `-S` | Output LLVM IR only (no binary) | | `--keep-temps` | Keep intermediate files (`.ll`, `.o`) | | `-fsanitize=address` | Build with AddressSanitizer (ASAN) | +| `--link-obj ` | Link an external object file or static library (repeatable) | ## Cross-Compilation diff --git a/docs/language/limitations.md b/docs/language/limitations.md index e0e69437..8ec9fab7 100644 --- a/docs/language/limitations.md +++ b/docs/language/limitations.md @@ -39,6 +39,7 @@ ChadScript supports a practical subset of TypeScript. All types must be known at | Default parameters | Supported | | Rest parameters (`...args`) | Supported | | Closures | Supported (capture by value, not by reference) | +| `declare function` (FFI) | Supported (see [FFI](#foreign-function-interface-ffi)) | | Async generators / `for await...of` | Not supported | ## Types and Data Structures @@ -111,6 +112,61 @@ ChadScript supports a practical subset of TypeScript. All types must be known at | `.then()`, `.catch()`, `.finally()` | Supported | | `setTimeout`, `setInterval`, `clearTimeout`, `clearInterval` | Supported | +## JSX + +| Feature | Status | +|---------|--------| +| JSX elements (``) | Supported (desugared to `createElement()` calls) | +| Fragments (`<>...`) | Supported | +| Expression attributes (`prop={expr}`) | Supported | +| String attributes (`prop="text"`) | Supported | +| Self-closing elements (``) | Supported | +| Nested elements | Supported | + +JSX is desugared at parse time into `createElement(tag, props, children)` calls. You provide the `createElement` function — ChadScript doesn't ship a framework. Files must use `.tsx` extension. + +```tsx +interface Props { + text: string; + color: number; +} + +function createElement(tag: string, props: Props, children: string[]): string { + // your rendering logic here + return tag; +} + +const ui =