This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Arcane is a custom programming language compiler written in Elixir. It's inspired by Elixir, Odin, and JavaScript, designed to compile to multiple backends including LLVM IR for native binaries and Nix expressions for system configuration.
# Install dependencies
mix deps.get
# Run tests
mix test
# Run specific test file
mix test test/path/to/test_file.exs
# Run tests with coverage
mix test --cover
# Generate documentation
mix docs
# Start interactive shell with project loaded
iex -S mix
# Format code
mix formatThe compiler can be used interactively in iex -S mix:
# Compile expression and dump LLVM IR to stdout
Arcane.compile_expression("some_expression")
# Compile expression and create executable
Arcane.compile_and_build("some_expression", "output_name")Source Code → Lexer → Parser → AST → S-expressions → Backend (LLVM IR/Nix/etc.) → Output
Core Entry Point:
Arcane- Main API module withcompile_expression/1andcompile_and_build/2
Parser Components:
Arcane.Parser- Main parser converting tokens to AST/S-expressionsArcane.Parser.Lexer- Tokenization of source codeArcane.Parser.Token- Token type definitionsArcane.Parser.Statement- Statement parsing logicArcane.Parser.Expression- Expression handlingArcane.Parser.Declaration- Declaration parsingArcane.Parser.Branch- Branch/conditional parsingArcane.Parser.Context- Parser context management
Compiler Components:
Arcane.Compiler- Main compiler API delegating to frontend/backendsArcane.Compiler.CompilerFrontend- S-expression generation from ASTArcane.Compiler.LLVMBackend- LLVM IR generation and executable creation
- Frontend:
Parser.pass_through()(currently bypassing actual parsing) - S-Expression Generation:
Compiler.compile_s_expression() - Backend Compilation:
Compiler.compile_llvm()for LLVM IR output or executable generation
- Compiled artifacts are placed in
./target/directory - LLVM IR files and executables are generated here
The language syntax (as documented in README.md) features:
- Module-based architecture similar to Elixir
- Explicit dependency declarations
- Arrow function syntax from JavaScript
- Type system with struct declarations
- Pattern matching for conditionals
- Resource management with
usingblocks and automatic cleanup - Tail call optimization for recursion
- Memory arena allocation for predictable performance
Based on recent commits, the project is focusing on:
- Boolean algebra implementation needed for conditional logic
- Branch expressions as a fundamental language construct
- Match expressions for pattern matching
- Statement/token relationship refinement
The parser currently uses pass_through() suggesting active development of the parsing pipeline.
- save this for later