Fusabi Frontend - Parser, Typechecker, and Bytecode Compiler
This crate implements the frontend of the Fusabi (F# Script Runtime System), responsible for parsing F# source code into an AST, performing type checking, and compiling to bytecode for the Fusabi VM.
Modules
ast: Core AST (Abstract Syntax Tree) definitionslexer: Lexer/Tokenizer for Mini-F# source codeparser: Recursive-descent parser for Mini-F# expressionscompiler: Bytecode compiler (AST → Bytecode)types: Type system infrastructure for Hindley-Milner type inferenceinference: Type inference engine (Hindley-Milner algorithm)typed_ast: Optional typed AST with type annotationsspan: Source location tracking for error reportingerror: Error types with beautiful formatting and suggestionsmodules: Module system for code organization
Example
use ;
use Lexer;
use Parser;
use ;
use TypeInference;
use TypeEnv;
// Full pipeline: source -> tokens -> AST -> type check -> bytecode
let source = "let x = 42 in x + 1";
let mut lexer = new;
let tokens = lexer.tokenize.unwrap;
let mut parser = new;
let ast = parser.parse.unwrap;
// Type check
let mut infer = new;
let env = new;
let ty = infer.infer_and_solve.unwrap;
// Compile without type checking (backward compatible)
let chunk = compile.unwrap;
// Or compile with type checking enabled
let options = CompileOptions ;
let chunk_checked = compile_with_options.unwrap;
// Chunk is ready for VM execution
assert!;