-
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, this wiki will walk you through every part of the pipeline.
CDTk provides a unified, memory‑safe architecture for:
- Lexing
- Parsing
- AST construction
- Semantic analysis
- Mapping and transformation
All of these stages are strongly typed and declarative, forming a single coherent pipeline:
Tokens → Rules → AST → Semantics → Output
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 three foundational components:
- TokenSet — defines the lexical vocabulary
- RuleSet — defines grammar rules and constructs the AST
- MapSet — defines semantic mappings and transformations
These components interlock cleanly, allowing you to describe your entire language in one place with full type safety and predictable behavior.
CDTk is engineered for high‑throughput compilation while remaining fully memory‑safe.
Recent backend improvements deliver:
- 50–200M characters/sec DFA‑based lexing
- Multi‑million nodes/sec table‑driven parsing
- 14M+ operations/sec semantic dispatch
- Zero allocations in hot paths
- Deterministic, branch‑predictable execution
All of this is achieved using safe C# only — no pointers, no unsafe blocks, no stackalloc, and no custom allocators.
CDTk places no restrictions on grammar shape. The RuleSet system supports:
- Left recursion
- Right recursion
- Ambiguous grammars
- Operator‑precedence patterns
- Deeply nested constructs
- Arbitrary AST structures
This flexibility allows CDTk to model everything from tiny DSLs to full programming languages with ease.
CDTk’s API is designed to be:
- Strongly typed — every token, rule, node, and mapping is a real C# type
- Declarative — define your language structure without boilerplate
- Memory‑safe — no unsafe code anywhere in the pipeline
- Minimal — entire compilers can be defined in a single file
- Predictable — freeze‑based architecture ensures deterministic behavior
The result is a compiler framework that feels lightweight and expressive while still offering the performance of a hand‑written engine.
Use the navigation sidebar to explore topics such as:
- Getting started
- Token and rule definition
- AST construction
- Semantic metadata and scopes
- Performance architecture
- Full examples and patterns
This wiki is the best place to learn how CDTk works and how to build your own language with it.
Contributions, issues, and feature requests are welcome.
See the project’s Contributing Guidelines:
https://github.com/Tristin-Porter/CDTk/wiki/Contributing
- Learn: Learn to use CDTk.
- Pipeline: Learn about the design of CDTk.
- Performance: Learn about the performance of CDTk.