How aquice/dim works
Project type and purpose
• This is a language implementation ("DIM Programming Language") written in C++. It provides a complete pipeline from reading source code through lexing, parsing, casting (type processing), and finally interpreting/running code.
File structure
• Top-level:
• CMakeLists.txt (build config)
• main.dim (sample program)
• master.py (helper/script for running tests or bootstrapping)
• README.md (language spec)
• / and src/ mirror each other and contain four submodules:
• lexer (lexical analysis)
• parser (AST & casting)
• runner/interpreter (execution engine with register and value abstractions)
• utils (shared helpers)
• src/main.cxx ties everything together as the CLI driver.
Insights from the README
• Describes language features (data types, operators, control flow).
• No functions yet—everything lives in a global scope.
• Emphasizes that every statement produces a value (important for interpreter design).
Main components and their relationships
a. Components:
1) Driver/CLI (main.cxx)
2) Lexer (lexer.cxx / lexer.hxx)
3) Parser & AST (parser.cxx / ast.hxx)
4) Caster/Semantic Pass (cast.cxx / cast.hxx)
5) Interpreter (interprets AST nodes)
• Register module (register.cxx / register.hxx)
• Value module (value.cxx / value.hxx)
6) Utilities (utils.cxx / utils.hxx)
7) Build System (CMake)
8) Runner script (master.py)
9) Sample program (main.dim)
b. Interactions & data flow:
• CLI reads main.dim →
• passes source text to Lexer →
• token stream to Parser →
• AST to Caster →
• typed AST to Interpreter →
• Interpreter uses Register & Value modules to evaluate →
• results/output to console.
• Utils are called by lexer/parser/interpreter for shared tasks (e.g., error reporting, I/O).
c. Architectural patterns/design principles:
• Pipeline pattern (lex → parse → semantic → eval)
• Separation of concerns (each stage in its own directory)
• Header/source mirroring for clear API boundaries
• Single-responsibility modules (lexer only lexes, parser only builds AST, etc.)
d. Key technologies/frameworks:
• C++17 (or newer)
• CMake as build/config tool
• Python (master.py) for test harness or bootstrapping
• Custom AST data structures in parser/ast.hxx
Detail
• Every module as its own component—even small utility modules—to capture the full architecture.
• How the CMakeLists.txt orchestrates building of all submodules.
• That every stage depends on the previous one’s output type.