xanascript
v2.2.8
Published
Programming language with Portuguese syntax, optimizing compiler, built-in ORM, and WebAssembly support
Maintainers
Readme
Installation
npm install -g xanascriptNode.js 18+ required.
Quick Start
PARTIU()
CHAMA ESSE CARA fib(n) {
SE LIGA SO (n <= 1) { VOLTA n }
VOLTA fib(n - 1) + fib(n - 2)
}
SOLTA O GRITO("fib(10) =", fib(10))
ACABOU()xs run hello.xsDocumentation
| Language | Link | |----------|------| | English | Getting Started | | Português | Começando | | Español | Introducción | | LLM Reference | llms.txt |
Features
- Portuguese syntax — keywords in Portuguese for accessibility
- Optimizing compiler — generates JavaScript and WebAssembly
- Built-in ORM —
CRIA REPOSITORIOfor database operations - Package manager —
xs install,xs publishvia xanascript.xyz/packages - LSP support — IDE integration with diagnostics and autocomplete
- Bytecode VM — stack-based virtual machine for fast execution
- Macros — compile-time code generation and transformation
- Test runner — native test framework (
xs test) - Source maps — error mapping back to
.xssource lines
CLI
xs run <file> Execute .xs (AST interpreter)
xs vm <file> Execute .xs (bytecode VM)
xs check <file> Check syntax
xs fmt <file> Format code
xs build <file> Generate JavaScript
xs build --opt <file> Optimized JS with type inference
xs build --wasm <file> WebAssembly output
xs build --standalone Single-file JS with runtime
xs test Run tests (*test*.xs)
xs dev <file> Watch mode with hot reload
xs repl Interactive REPL
xs lsp Language Server Protocol
xs init [dir] Create new project
xs install <pkg> Install package from registry
xs publish Publish package to registry
xs search <term> Search packages
xs bench Run benchmarks
xs docs src/ out/ Generate HTML documentationArchitecture
.xs source → Lexer → Parser → Optimizer → Codegen (JS / Wasm / Bytecode)
↘ Interpreter (AST walk)| Module | Purpose |
|--------|---------|
| lexer.js | Tokenization with line/col tracking |
| parser.js | AST generation with error recovery |
| optimizer.js | Macros, constant folding, dead code elimination |
| interpreter.js | AST-walking interpreter |
| runtime.js | Built-in functions and environment |
| codegen.js | JavaScript code generation |
| codegen_opt.js | Optimized JS (TypedArrays, int32, type inference) |
| codegen_wasm.js | WebAssembly text format generation |
| wasm_binary.js | Direct Wasm binary generation (no wabt.js) |
| bytecode/ | Stack-based bytecode compiler and VM |
| pkgmgr.js | Package registry integration |
| lsp.js | Language Server Protocol implementation |
| testrunner.js | Native test framework |
| docsgen.js | HTML documentation generator |
| orm.js | Built-in ORM |
| macros.js | Compile-time macro expansion |
| errors.js | Rust-style error reporting with hints |
| sourcemap.js | JS→XS source mapping |
Ecosystem
| Repository | Description | |---|---| | xs | Core language | | xs-site | Website and package registry | | xs-vscode | VS Code extension | | xs-examples | Code examples |
