How hanneskimara/cddlc works
Project Type and Purpose
• This is a compiler‐style toolchain in Go for the IETF’s CDDL (Concise Data Definition Language).
• It provides both a Go library (parser, AST, code generators, runtime validators) and a CLI tool (cddlc) to generate Go code and REPL support from CDDL specs.
File Structure
• Top-Level CLI:
• cmd/cddlc/main.go
• cmd/cddlc/commands/{init,generate,repl}.go
• Compiler Phases:
• Lexer: lexer/lexer.go, lexer_test.go
• Parser: parser/parser.go, parser/diagnostic.go
• AST: ast/*.go + ast/astutils
• Transforms/Codegen: transforms/codegen/generator.go + language-specific (golang) generators
• Supporting Services:
• Config: config/config.go
• Environment: environment/environment.go (+ tests)
• Errors: errors/errors.go
• Runtime Validators: runtime/validators/*.go
• Helpers:
• Token definitions: token/token.go, token/position.go
• Examples & Testdata: examples/, testdata/
• Build & Release: Makefile, .goreleaser.yaml, GitHub actions
Insights from README
• Purpose: parse CDDL and generate Go types/validators for CBOR/JSON.
• Dual interface: library and the cddlc command.
• Feature coverage table indicates which CDDL constructs are parsed vs. code-generated.