Installation
Build the compiler from source:Commands
elara build
Compile an Elara program to JVM bytecode without running it.
Path to the main Elara source file to compile. Must contain a
Main module with a main : IO () function.Options
Comma-separated list of intermediate compilation stages to dump to files.Valid values:
lexed- Lexer output (tokens)parsed- Frontend ASTdesugared- Desugared ASTrenamed- Renamed ASTshunted- Shunted AST (after operator precedence)typed- Typed ASTcore- Core IR (and ANF, closure-lifted variants)ir- JVM IRjvm- JVM bytecode disassembly
--dump=core,jvmEnvironment variable: ELARA_DUMPComma-separated list of directories to search for source files.Example:
--source-dirs=lib,srcEnvironment variable: ELARA_SOURCE_DIRSExamples
Output
Compiled class files are written to thebuild/ directory:
elara run
Compile and execute an Elara program.
Path to the main Elara source file to run.
Arguments to pass to the program being run (after
--).Options
Execution target. Determines how the program runs.Valid values:
interp- Run using the Core interpreter (fast compilation, slower execution)jvm- Compile to JVM bytecode and run (slower compilation, faster execution)
--target=jvmSame as
elara build --dump.Same as
elara build --source-dirs.Examples
Output
- Interpreter
- JVM
Global Options
These options work with all commands:Display help information and exit.
Display compiler version and exit.
Environment Variables
Same as
--dump flag. Command-line flags override environment variables.Same as
--source-dirs flag. Command-line flags override environment variables.Enable debug logging. Set to
1 or true to enable.Set minimum log level.Valid values:
debug, info, warning, errorConfiguration Files
Elara supports YAML configuration files for project settings.Location
The compiler searches for configuration in this order:./elara.yaml(current directory)./elara.yml~/.config/elara/config.yaml
Format
elara.yaml
Command-line flags override configuration file settings, which override environment variables.
Dump Targets Reference
Each dump target writes intermediate compilation artifacts to thebuild/ directory.
lexed
lexed
File:
build/<module>.lexed.elrContent: Token stream with layout rules appliedparsed
parsed
File:
build/<module>.parsed.elrContent: Frontend AST (directly mirrors source syntax)desugared
desugared
File:
build/<module>.desugared.elrContent: Desugared AST (multi-arg lambdas curried, let params removed)renamed
renamed
File:
build/<module>.renamed.elrContent: Renamed AST (all names fully qualified and unique)shunted
shunted
File:
build/<module>.shunted.elrContent: Shunted AST (operators in prefix form, precedence applied)typed
typed
File:
build/<module>.typed.elrContent: Typed AST (every expression annotated with its type)core
core
Files:
build/<module>.core.elr- Initial Core IRbuild/<module>.core.anf.elr- A-Normal Formbuild/<module>.core.closure_lifted.elr- After closure liftingbuild/<module>.core.final.elr- Final optimized Core
ir
ir
File:
build/<module>.jvm.ir.elrContent: JVM intermediate representation (before bytecode)jvm
jvm
File:
build/<module>.classfile.txtContent: JVM bytecode disassemblyExit Codes
Compilation/execution succeeded
Compilation or runtime error occurred
Invalid command-line arguments
Logging
The compiler writes logs to:- Standard output - Colored, formatted output
elara.log- Plain text log file in current directory
Log Format
Controlling Log Output
Examples
Basic Workflow
Debug Compilation Issues
Multi-Module Project
elara.yaml
Troubleshooting
Module not found
Module not found
Error:Solution:
- Check that the module file exists
- Add the directory to
--source-dirs: - Verify the module name matches the file name
Java heap space error
Java heap space error
Error:Solution: Increase JVM heap size:
Class not found at runtime
Class not found at runtime
Error:Solution: Ensure both
build/ and jvm-stdlib/ are in classpath:Permission denied
Permission denied
Error:Solution:
Related Pages
Compiler Architecture
Learn about the compiler’s internal design
Compilation Pipeline
Understand the 9 compilation stages