JavaScript interpreter in MoonBit
token/ Token types and source locations
lexer/ Tokenizer
ast/ AST node definitions
parser/ Recursive descent parser with Pratt precedence
interpreter/ Tree-walking evaluator with closures and scope chains
cmd/main/ CLI entry pointmoon run cmd/main -- 'console.log(1 + 2)'
# 3moon run cmd/main -- '
function fib(n) {
if (n <= 1) { return n; }
return fib(n - 1) + fib(n - 2);
}
console.log(fib(10));
'
# 55let (output, result) = @js_engine.run("console.log(1 + 2)")
// output = ["3"], result = "undefined"moon check # Type check
moon fmt # Format code
moon info # Update .mbti interface files
moon test # Run tests
moon test --update # Update snapshot tests
moon build # Build