cddltool

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cddltool implements a real parser and structural validator for the CDDL subset used by spec/v1/wire-messages.cddl. It is not a general-purpose CDDL implementation: it deliberately supports exactly the constructs the protocol truth uses — rule definitions with '=' and '/=', unions, arrays with labelled entries and occurrence indicators, integer/text literals, numeric ranges, and the .size/.cbor/.le/.gt control operators — so that a grammar mistake, an undefined reference, or a wire message violating the published shape fails loudly instead of silently.

The validator decodes CBOR strictly (no tags, no indefinite lengths, no trailing bytes) before matching it against a rule, which makes golden positives and hand-built negatives meaningful conformance signals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spec

type Spec struct {
	// contains filtered or unexported fields
}

Spec is a fully parsed CDDL document.

func Parse

func Parse(source string) (*Spec, error)

Parse parses complete CDDL source. Duplicate rules, undefined references, and unsupported constructs are errors.

func (*Spec) RuleNames

func (s *Spec) RuleNames() []string

func (*Spec) Validate

func (s *Spec) Validate(ruleName string, data []byte) error

Validate decodes data strictly and matches it against the named rule. When the rule is a union, any matching alternative succeeds; otherwise the first failure description is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL