Skip to content
Tristin Porter edited this page Jan 9, 2026 · 3 revisions

Welcome to the CDTk Wiki

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.


What CDTk Is

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#.


Core Architecture

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.


Performance at Scale

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.


Supports Any Grammar

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.


Simple, Typed, and Safe API

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.


Explore the Wiki

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.


Contributing

Contributions, issues, and feature requests are welcome.
See the project’s Contributing Guidelines:

https://github.com/Tristin-Porter/CDTk/wiki/Contributing


Next Steps

Clone this wiki locally