-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This wiki is your guide to understanding, exploring, and building with CDTk - Compiler Description Toolkit.
CDTk is a modern, strongly typed compiler framework for C#, designed to make language implementation fast, safe, and expressive. Whether you're creating a small DSL or a full programming language. It provides a unified, memory-safe pipeline for:
- Lexing (TokenSet)
- Parsing (RuleSet)
- Semantic Analysis (Scope / Models)
- Code Generation (MapSet)
There are no external tools, no code generation templates, and no hidden behavior - just a clear, extensible compiler architecture built entirely in safe C#.
CDTk is built on four foundational components:
- TokenSet - defines the lexical vocabulary
- RuleSet - defines grammar rules and constructs the AST
- MapSet - defines semantic mappings and output transformations
These components interlock cleanly, allowing you to describe your entire language in one place with full type safety and predictable behavior. Grammar modules are regular C# classes that you inherit from, and CDTk discovers their fields via reflection at construction time.
CDTk is engineered for high-throughput compilation while remaining fully memory-safe. Recent backend improvements deliver:
- 100-200M characters/sec DFA-based lexing
- 5-10M AST nodes/sec table-driven parsing
- 15M+ operations/sec semantic dispatch
- Zero allocations in hot paths
- Deterministic, branch-predictable execution
All achieved using safe C# only - no pointers, no unsafe blocks, no stackalloc, no custom allocators.
CDTk’s grammar system is intentionally flexible, placing no structural constraints on how a language must be expressed. Its rule engine is designed to accommodate virtually any syntactic pattern or organizational style a language designer might choose, allowing you to shape your grammar as freely and creatively as your language requires.
CDTk's API is:
- Strongly typed
- Declarative
- Memory-safe
- Minimal
- Predictable
Use the sidebar to navigate through the documentation. It’s arranged in a natural learning order, with introductory material at the top and more advanced topics toward the bottom. Each page also includes suggested next steps to help guide your progression through the toolkit.
Contributions, issues, and feature requests are welcome. See the project's Contributing Guidelines: https://github.com/Tristin-Porter/CDTk/wiki/Contributing