How xomagat/fabsharp works
FAB# is a C++ compiler for a compiled language: users submit .fab source and receive a standalone executable, optionally running it immediately. The documented flow passes through command-line handling, lexing, parsing, LLVM code generation, object compilation and linking. The parser and AST cover language constructs; manifests describe standard-library symbols, with type methods always available and other libraries loaded on demand. The README and source index establish the main flow, but many implementation details—especially linking and individual AST code generation—were not sampled.
Main entry points: Parser.cpp Parser · main.cpp Compiler CLI · STDLibInfo.h Library manifests · Compile.cpp Object compilation
Components 19
Frontend
- Compiler CLI
main.cpp - Lexer
Parser/Lexer.cpp - Parser
Parser/Parser.cpp
Language AST
- Expressions
Parser/AST/Expression.h - Statements
Parser/AST/Statement.h - Assignments
Parser/AST/AssigementStatement.h - Functions
Parser/AST/FunctionStatement.h - Classes
Parser/AST/ClassStatement.h
Code Generation
- Codegen context
CodeGen/CodegenContext.h - Object compilation
CodeGen/Compile.cpp
Standard Library
- Library manifests
libs/STDLibInfo.h - Type methods
lib/types - List and dict
lib/types/list.cpp - Optional libraries
lib/libs - Runtime support
lib/alloc.cpp
Build Output
- Executable linking
CodeGen/Compile.cpp - Standalone program
Other components
- Program author
- LLVM
Connections 21
- Program author → Compiler CLI: provides source
- Compiler CLI → Lexer: starts lexing
main.cpp - Compiler CLI → Parser: starts parsing
main.cpp - Lexer → Parser: supplies tokens
- Parser → Expressions: builds expressions
- Parser → Statements: builds statements
- Parser → Assignments: builds assignments
- Parser → Functions: builds functions
- Parser → Classes: builds classes
- Compiler CLI → Object compilation: invokes compilation
main.cpp - Object compilation → Codegen context: uses context
- Codegen context → LLVM: emits LLVM IR
- Library manifests → Type methods: describes symbols
- Library manifests → Optional libraries: describes symbols
- Library manifests → List and dict: describes symbols
- Compiler CLI → Library manifests: loads manifests
- Object compilation → Executable linking: links output
- Executable linking → Standalone program: produces executable
- Compiler CLI → Standalone program: may run after build
- Type methods → Runtime support: uses runtime
- List and dict → Runtime support: allocates memory
lib/types/list.cpp