How daftyon/easier-language works
Project Type & Purpose
• This is a domain-specific language implementation (a compiler/interpreter) named “EasierLang” (EL), complete with a CLI, build scripts, and packaging.
• Its goal is to take .el source files, perform lexical analysis, parsing, semantic analysis, and then either interpret them directly or package them into executables.
High-Level Components
A. CLI Frontend
– el_cli.py / main.py: Entry point for user commands (el run, el build, etc.)
– Dockerfile / quick_build.bat: Environment setup & containerized builds
B. Lexical Analyzer
– compiler/lexer.py: Tokenizes .el source into token stream (see tokens.py)
C. Parser & AST Builder
– compiler/parser.py: Parses tokens into an Abstract Syntax Tree (AST)
– utils/data_classes.py: Defines AST node data structures
D. Semantic Analyzer & Symbol Management
– compiler/semantic_analyzer.py: Enforces type rules, scoping
– compiler/symbol_table.py & compiler/scopes.py: Manage symbol tables and nested scopes
– utils/constants.py, utils/errors.py: Definitions & error handling support
E. Interpreter / Execution Engine
– compiler/interpreter.py: Walks the AST, executes statements, evaluates expressions, handles built-ins
– system/…: Built-in functions (system/builtin_functions), objects (system/objects)
F. Build & Packaging
– build_direct.py & build_executable.py: Scripts that bundle the interpreter and stdlib into a standalone package
– build/el/: Generated artifacts (pyz, toc, exe)
– setup.py / pyproject.toml: Python packaging & distribution
G. Examples & Tests
– examples/: Sample .el programs
– tests.py / src/test.el: Automated or manual tests
Component Interactions & Data Flow
– User invokes CLI → CLI parses flags → CLI calls the Compiler Driver (main.py)
– Driver loads source files from disk → passes text to Lexical Analyzer → produces token stream
– Token stream flows into Parser → builds AST
– AST flows into Semantic Analyzer → performs type checking and symbol resolution
– Either:
• Interpreter consumes checked AST → executes code and interacts with built-ins
• OR Build scripts consume the AST/bundled interpreter to produce standalone executables (EL packages)
– Errors at each phase bubble up to CLI → presented to user
Architectural Patterns & Principles
• Classic compiler pipeline: Lexing → Parsing → Semantic Analysis → Interpretation/Code Generation
• Clear separation of concerns:
– compiler/ for all language processors
– system/ for runtime library & built-ins
– utils/ for shared data structures & error handling
• Packaging layer sits orthogonal to language pipeline