How ella-to/ella works
Project Type and Purpose
• Ella is a standalone compiler CLI tool (written in Go) that reads .ella schema files and emits Go and TypeScript code.
• Its core responsibility is to parse a simple IDL, build an AST, validate it, and run code generators (Go & TS).
File Structure
• Top‐level files:
• main.go – CLI entry point.
• go.mod, go.sum – module configuration.
• Makefile – build/test scripts.
• README.md, LICENSE, .gitignore.
• Directories:
• internal/compiler – core compiler pipeline:
– scanner/ – lexical analysis (lexer & token definitions).
– parser/ – syntactic analysis + validation.
– ast/ – in‐memory schema representation.
– gen/ – code generators (Go & TS templates).
• internal/strcase – utility for converting identifier case styles.
• e2e – end‐to‐end schema examples & tests (download, HTTP, RPC, stream, upload).
Key Insights from README
• CLI commands (gen, fmt, ver) orchestrate the pipeline.
• Designed for easy extension: to add another target language, implement a new generator in internal/compiler/gen.
• E2E folder demonstrates supported service patterns (JSON/JSON, Streams, RPC).
Main Components & Their Interactions
a. CLI Layer
– Parses arguments (gen, fmt).
– Invokes the compiler pipeline.
b. Pipeline Stages
1. Scanner: Reads .ella files → produces Token stream.
2. Parser: Consumes tokens → builds AST + performs semantic validations.
3. AST: Shared in‐memory model of schemas (constants, enums, models, services, errors).
4. Generator Factory:
• Chooses Go or TS generator based on output extension.
• Feeds AST into templating engine (text/template or similar).
5. Output Writer:
• Emits .gen.go or .gen.ts files.
c. Utilities
– strcase for consistent identifier casing in generated code.
– E2E tests for validating end‐to‐end generation scenarios.
Architectural Patterns & Principles
• Compiler Pipeline (Lex → Parse → AST → Generate)
• Template‐based Code Generation (separate templates for Go & TS)
• Single‐binary CLI with pluggable generators
• Clear separation: core compiler vs. language‐specific generators vs. utilities vs. tests