Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
# API Reference
|
|
|
|
|
|
2026-03-01 17:00:39 +02:00
|
|
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
|
|
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
|
|
|
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
|
|
|
|
|
|
|
|
|
- [Command-Line Interface](#command-line-interface)
|
|
|
|
|
- [Synopsis](#synopsis)
|
|
|
|
|
- [Options](#options)
|
|
|
|
|
- [`-o, --output <file>`](#-o-output)
|
|
|
|
|
- [`--output-dir <dir>`](#-output-dir)
|
|
|
|
|
- [`--lang <language>`](#-lang)
|
|
|
|
|
- [`--c`](#-c)
|
|
|
|
|
- [`--check-imports`](#-check-imports)
|
|
|
|
|
- [`--crate-imports`](#-crate-imports)
|
|
|
|
|
- [`--super-imports`](#-super-imports)
|
|
|
|
|
- [`--module-prefix <prefix>`](#-module-prefix)
|
|
|
|
|
- [`--use-core`](#-use-core)
|
|
|
|
|
- [`--header-path <path>`](#-header-path)
|
|
|
|
|
- [`--with-helpers`](#-with-helpers)
|
|
|
|
|
- [`--arena`](#-arena)
|
|
|
|
|
- [`--impl <header>`](#-impl)
|
|
|
|
|
- [`--emit <artifacts>`](#-emit)
|
|
|
|
|
- [`--cmake`](#-cmake)
|
|
|
|
|
- [`--meson`](#-meson)
|
|
|
|
|
- [`--shared`](#-shared)
|
|
|
|
|
- [`--synta-root <dir>`](#-synta-root)
|
|
|
|
|
- [Examples](#examples)
|
|
|
|
|
- [Library API -- Rust generation](#library-api-rust-generation)
|
|
|
|
|
- [`parse`](#parse)
|
|
|
|
|
- [`generate`](#generate)
|
|
|
|
|
- [`generate_with_config`](#generatewithconfig)
|
|
|
|
|
- [`CodeGenConfig`](#codegenconfig)
|
|
|
|
|
- [`ImportMode`](#importmode)
|
|
|
|
|
- [Library API -- C generation](#library-api-c-generation)
|
|
|
|
|
- [`generate_c`](#generate_c)
|
|
|
|
|
- [`generate_c_with_config`](#generatecwith_config)
|
|
|
|
|
- [`CCodeGenConfig`](#ccodegenconfig)
|
|
|
|
|
- [`generate_c_impl`](#generatecimpl)
|
|
|
|
|
- [`CImplConfig`](#cimplconfig)
|
|
|
|
|
- [AST types](#ast-types)
|
|
|
|
|
- [`Module`](#module)
|
|
|
|
|
- [`Definition`](#definition)
|
|
|
|
|
- [`ParseError`](#parseerror)
|
|
|
|
|
- [See Also](#see-also)
|
|
|
|
|
|
|
|
|
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
Complete reference for the synta-codegen library and command-line interface.
|
|
|
|
|
|
|
|
|
|
---
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
## Command-Line Interface
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
### Synopsis
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
```
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
synta-codegen [OPTIONS] <input.asn1> [extra.asn1 ...]
|
|
|
|
|
```
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
### Options
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
#### `-o, --output <file>`
|
|
|
|
|
|
|
|
|
|
Write output to `file`. Default: stdout.
|
|
|
|
|
|
|
|
|
|
#### `--output-dir <dir>`
|
|
|
|
|
|
|
|
|
|
Write one generated file per input module into `dir`. Files are written in
|
|
|
|
|
topological dependency order (base modules first). Cannot be combined with `-o`.
|
|
|
|
|
|
|
|
|
|
#### `--lang <language>`
|
|
|
|
|
|
|
|
|
|
Target language. Accepted values: `rust` (default), `c`.
|
|
|
|
|
|
|
|
|
|
#### `--c`
|
|
|
|
|
|
|
|
|
|
Shorthand for `--lang c`.
|
|
|
|
|
|
|
|
|
|
#### `--check-imports`
|
|
|
|
|
|
|
|
|
|
Parse all input files and check for circular module import cycles. If a cycle is
|
|
|
|
|
detected, report it and exit with a non-zero status. No code is generated.
|
|
|
|
|
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
#### `--crate-imports`
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
|
|
|
|
|
Rust only. Emit `use crate::module::Type` statements for imported ASN.1 types.
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
#### `--super-imports`
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
Rust only. Emit `use super::module::Type` statements for imported ASN.1 types.
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
#### `--module-prefix <prefix>`
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
Rust only. Emit `use <prefix>::module::Type` statements. The prefix is used
|
|
|
|
|
verbatim followed by `::`.
|
|
|
|
|
|
|
|
|
|
#### `--use-core`
|
|
|
|
|
|
|
|
|
|
Rust only. Replace `std::` paths with `core::` equivalents in generated code
|
|
|
|
|
(no_std environments).
|
|
|
|
|
|
|
|
|
|
#### `--header-path <path>`
|
|
|
|
|
|
|
|
|
|
C only. Path written into the `#include "..."` directive for `synta.h` in the
|
|
|
|
|
generated header. Default: `"synta.h"`.
|
|
|
|
|
|
|
|
|
|
#### `--with-helpers`
|
|
|
|
|
|
|
|
|
|
C only. Generate `_init`, `_validate`, and `_print` inline helper functions for
|
|
|
|
|
every type.
|
|
|
|
|
|
|
|
|
|
#### `--arena`
|
|
|
|
|
|
|
|
|
|
C only. Generate the `SyntaArena` type and `_decode_arena()` function prototypes
|
|
|
|
|
(in the header) or bodies (in the implementation).
|
|
|
|
|
|
|
|
|
|
#### `--impl <header>`
|
|
|
|
|
|
2026-02-28 09:49:27 +02:00
|
|
|
C only. Single-file mode: generate a `.c` implementation file instead of a `.h`
|
|
|
|
|
header file. The argument specifies the name of the corresponding header file,
|
|
|
|
|
which is placed in the generated `#include "..."` directive. Not compatible with
|
|
|
|
|
`--output-dir` and multiple input files; use `--emit` instead.
|
|
|
|
|
|
|
|
|
|
#### `--emit <artifacts>`
|
|
|
|
|
|
|
|
|
|
C only. Used with `--output-dir`. Controls which artifacts are written per
|
|
|
|
|
module. Accepted values:
|
|
|
|
|
|
|
|
|
|
- `header` (default) — write only `.h` header files.
|
|
|
|
|
- `impl` — write only `.c` implementation files.
|
|
|
|
|
- `both` — write both `.h` and `.c` files for each module.
|
|
|
|
|
|
|
|
|
|
When `--cmake` or `--meson` is combined with `--output-dir`, `--emit` defaults
|
|
|
|
|
to `both` automatically so the generated build file's source references are
|
|
|
|
|
satisfied.
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
|
|
|
|
|
#### `--cmake`
|
|
|
|
|
|
2026-02-28 09:49:27 +02:00
|
|
|
Generate a `CMakeLists.txt` build file. Without `--output-dir`, writes only the
|
|
|
|
|
build file (to stdout or `-o`). With `--output-dir`, also generates C source
|
|
|
|
|
files (equivalent to `--emit both`) so the build file's `.c` references are
|
|
|
|
|
immediately satisfied.
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
|
|
|
|
|
#### `--meson`
|
|
|
|
|
|
2026-02-28 09:49:27 +02:00
|
|
|
Generate a `meson.build` file. Without `--output-dir`, writes only the build
|
|
|
|
|
file (to stdout or `-o`). With `--output-dir`, also generates C source files
|
|
|
|
|
(equivalent to `--emit both`).
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
|
|
|
|
|
#### `--shared`
|
|
|
|
|
|
|
|
|
|
Used with `--cmake` or `--meson`. Configure the generated build file to build a
|
|
|
|
|
shared library instead of a static library.
|
|
|
|
|
|
|
|
|
|
#### `--synta-root <dir>`
|
|
|
|
|
|
|
|
|
|
Used with `--cmake` or `--meson`. Embed `dir` as the hard-coded path to the synta
|
|
|
|
|
installation in the generated build file.
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
**Rust: single file**
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
synta-codegen schema.asn1 -o src/generated.rs
|
|
|
|
|
synta-codegen schema.asn1 --crate-imports -o src/generated.rs
|
|
|
|
|
synta-codegen schema.asn1 --super-imports -o src/generated.rs
|
|
|
|
|
synta-codegen schema.asn1 --module-prefix my_lib -o src/generated.rs
|
|
|
|
|
synta-codegen schema.asn1 --use-core -o src/generated.rs
|
|
|
|
|
cat schema.asn1 | synta-codegen > generated.rs
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
**Rust: multi-file output**
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
synta-codegen base.asn1 user.asn1 --crate-imports --output-dir src/gen/
|
|
|
|
|
synta-codegen base.asn1 user.asn1 --check-imports
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
**C: header and implementation**
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
synta-codegen schema.asn1 --c -o generated.h
|
|
|
|
|
synta-codegen schema.asn1 --impl generated.h -o generated.c
|
|
|
|
|
synta-codegen schema.asn1 --c --with-helpers -o generated.h
|
|
|
|
|
synta-codegen schema.asn1 --c --arena -o generated.h
|
|
|
|
|
synta-codegen schema.asn1 --impl generated.h --arena -o generated.c
|
|
|
|
|
synta-codegen schema.asn1 --c --header-path "../../include/synta.h" -o generated.h
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
**C: multi-file output**
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
synta-codegen base.asn1 user.asn1 --c --output-dir ./generated/
|
2026-02-28 09:49:27 +02:00
|
|
|
synta-codegen base.asn1 user.asn1 --c --emit both --output-dir ./generated/
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
synta-codegen base.asn1 user.asn1 --check-imports
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Build system files**
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
synta-codegen schema.asn1 --cmake -o CMakeLists.txt
|
|
|
|
|
synta-codegen schema.asn1 --meson -o meson.build
|
|
|
|
|
synta-codegen base.asn1 user.asn1 --cmake --output-dir ./generated/
|
|
|
|
|
synta-codegen schema.asn1 --cmake --synta-root /opt/synta -o CMakeLists.txt
|
|
|
|
|
synta-codegen schema.asn1 --cmake --shared -o CMakeLists.txt
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
## Library API -- Rust generation
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
### `parse`
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
```rust
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
pub fn parse(input: &str) -> Result<Module, ParseError>
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
Parse an ASN.1 module definition from `input`. Returns the parsed AST on success
|
|
|
|
|
or a `ParseError` with line and column information on failure. Accepts exactly one
|
|
|
|
|
module per call.
|
|
|
|
|
|
|
|
|
|
### `generate`
|
|
|
|
|
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```rust
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
pub fn generate(module: &Module) -> Result<String, std::fmt::Error>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Generate Rust source code for `module` using default configuration: no import
|
|
|
|
|
statements emitted, `std::` paths used.
|
|
|
|
|
|
|
|
|
|
### `generate_with_config`
|
|
|
|
|
|
|
|
|
|
```rust
|
|
|
|
|
pub fn generate_with_config(
|
|
|
|
|
module: &Module,
|
|
|
|
|
config: CodeGenConfig,
|
|
|
|
|
) -> Result<String, std::fmt::Error>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Generate Rust source code applying the settings in `config`.
|
|
|
|
|
|
|
|
|
|
### `CodeGenConfig`
|
|
|
|
|
|
|
|
|
|
```rust
|
|
|
|
|
pub struct CodeGenConfig {
|
|
|
|
|
pub import_mode: ImportMode,
|
|
|
|
|
pub use_core: bool,
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
- `import_mode` -- controls how ASN.1 IMPORTS are rendered as `use` statements.
|
|
|
|
|
- `use_core` -- when `true`, emits `core::` instead of `std::` in generated paths.
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
### `ImportMode`
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
```rust
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
pub enum ImportMode {
|
|
|
|
|
None,
|
|
|
|
|
Crate,
|
|
|
|
|
Super,
|
|
|
|
|
Prefix(String),
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
- `None` -- no `use` statements emitted for imported types (default).
|
|
|
|
|
- `Crate` -- emit `use crate::module::Type`.
|
|
|
|
|
- `Super` -- emit `use super::module::Type`.
|
|
|
|
|
- `Prefix(s)` -- emit `use s::module::Type`.
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
**Example:**
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```rust
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
use synta_codegen::{CodeGenConfig, ImportMode};
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
// No import statements
|
|
|
|
|
let config = CodeGenConfig { import_mode: ImportMode::None, use_core: false };
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
// Crate-relative imports
|
|
|
|
|
let config = CodeGenConfig { import_mode: ImportMode::Crate, use_core: false };
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
// Super-relative imports
|
|
|
|
|
let config = CodeGenConfig { import_mode: ImportMode::Super, use_core: false };
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
// Custom prefix
|
|
|
|
|
let config = CodeGenConfig {
|
|
|
|
|
import_mode: ImportMode::Prefix("my_lib".into()),
|
|
|
|
|
use_core: false,
|
|
|
|
|
};
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
// no_std
|
|
|
|
|
let config = CodeGenConfig { import_mode: ImportMode::None, use_core: true };
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
## Library API -- C generation
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
### `generate_c`
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
```rust
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
pub fn generate_c(module: &Module) -> Result<String, Box<dyn std::error::Error>>
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
Generate a C header file from `module` using default configuration.
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
### `generate_c_with_config`
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
|
|
|
|
|
```rust
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
pub fn generate_c_with_config(
|
|
|
|
|
module: &Module,
|
|
|
|
|
config: CCodeGenConfig,
|
|
|
|
|
) -> Result<String, Box<dyn std::error::Error>>
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
Generate a C header file applying the settings in `config`.
|
2026-02-25 17:29:40 +02:00
|
|
|
|
|
|
|
|
### `CCodeGenConfig`
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
```rust
|
|
|
|
|
pub struct CCodeGenConfig {
|
|
|
|
|
pub synta_header_path: Option<String>,
|
|
|
|
|
pub generate_helpers: bool,
|
|
|
|
|
pub arena_mode: bool,
|
|
|
|
|
}
|
|
|
|
|
```
|
2026-02-25 17:29:40 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
- `synta_header_path` -- path placed in `#include "..."` for `synta.h`. Default: `"synta.h"`.
|
|
|
|
|
- `generate_helpers` -- emit `_init`, `_validate`, and `_print` inline helpers. Default: `false`.
|
|
|
|
|
- `arena_mode` -- emit `SyntaArena` type and `_decode_arena()` prototypes. Default: `false`.
|
2026-02-25 17:29:40 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
Builder methods are available for convenience:
|
2026-02-25 17:29:40 +02:00
|
|
|
|
2026-02-28 23:45:19 +02:00
|
|
|
```rust,ignore
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
// Set custom synta.h include path
|
2026-02-25 17:29:40 +02:00
|
|
|
CCodeGenConfig::with_header_path("../../include/synta.h")
|
|
|
|
|
|
|
|
|
|
// Enable _init / _validate / _print helpers
|
|
|
|
|
config.with_helpers()
|
|
|
|
|
|
|
|
|
|
// Enable SyntaArena + _decode_arena() prototypes
|
|
|
|
|
config.with_arena()
|
|
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
**Example:**
|
|
|
|
|
|
2026-02-28 23:45:19 +02:00
|
|
|
```rust,ignore
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
use synta_codegen::{parse, generate_c_with_config, CCodeGenConfig};
|
|
|
|
|
|
|
|
|
|
let module = parse(schema)?;
|
2026-02-25 17:29:40 +02:00
|
|
|
let config = CCodeGenConfig::with_header_path("synta/synta.h")
|
|
|
|
|
.with_helpers()
|
|
|
|
|
.with_arena();
|
|
|
|
|
let header = generate_c_with_config(&module, config)?;
|
|
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
### `generate_c_impl`
|
2026-02-25 17:29:40 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
```rust
|
|
|
|
|
pub fn generate_c_impl(
|
|
|
|
|
module: &Module,
|
|
|
|
|
config: CImplConfig,
|
|
|
|
|
) -> Result<String, Box<dyn std::error::Error>>
|
|
|
|
|
```
|
2026-02-25 17:29:40 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
Generate a C implementation file (`.c`) from `module`.
|
2026-02-25 17:29:40 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
### `CImplConfig`
|
|
|
|
|
|
|
|
|
|
```rust
|
|
|
|
|
pub struct CImplConfig {
|
|
|
|
|
pub header_file: String,
|
|
|
|
|
pub arena_mode: bool,
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- `header_file` -- name of the corresponding header file, placed in the generated
|
|
|
|
|
`#include "..."` directive.
|
|
|
|
|
- `arena_mode` -- generate `_decode_arena()` function bodies. Default: `false`.
|
2026-02-25 17:29:40 +02:00
|
|
|
|
|
|
|
|
**Example:**
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
|
2026-02-25 17:29:40 +02:00
|
|
|
```rust
|
|
|
|
|
use synta_codegen::{parse, generate_c_impl, CImplConfig};
|
|
|
|
|
|
|
|
|
|
let module = parse(schema)?;
|
|
|
|
|
let impl_code = generate_c_impl(&module, CImplConfig {
|
|
|
|
|
header_file: "types.h".into(),
|
|
|
|
|
arena_mode: false,
|
|
|
|
|
})?;
|
|
|
|
|
```
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
---
|
2026-02-25 17:29:40 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
## AST types
|
2026-02-25 17:29:40 +02:00
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
These types are returned by `parse()` and consumed by the generation functions.
|
|
|
|
|
They are part of the public API but are primarily intended for tooling that needs
|
|
|
|
|
to inspect the parsed module.
|
|
|
|
|
|
|
|
|
|
### `Module`
|
|
|
|
|
|
|
|
|
|
```rust
|
|
|
|
|
pub struct Module {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub tagging: TaggingMode,
|
|
|
|
|
pub imports: Vec<Import>,
|
|
|
|
|
pub exports: Vec<String>,
|
|
|
|
|
pub definitions: Vec<Definition>,
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `Definition`
|
|
|
|
|
|
|
|
|
|
```rust
|
|
|
|
|
pub struct Definition {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub ty: Type,
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `ParseError`
|
|
|
|
|
|
|
|
|
|
```rust
|
|
|
|
|
pub struct ParseError {
|
|
|
|
|
pub message: String,
|
|
|
|
|
pub line: usize,
|
|
|
|
|
pub column: usize,
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`ParseError` implements `std::fmt::Display` and `std::error::Error`.
|
2026-02-25 17:29:40 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
Add comprehensive documentation suite
Created four new documentation files to make synta-codegen more accessible:
- docs/tutorial.md: Step-by-step tutorial from basic schemas to real-world
authentication protocol, covering constraints, optional fields, tagged
fields, and multi-file projects
- docs/troubleshooting.md: Comprehensive troubleshooting guide covering
installation issues, parsing errors, code generation issues, compilation
errors, runtime issues, and performance problems with solutions
- docs/best-practices.md: Production guidelines covering schema design,
code generation automation, project organization, performance optimization,
testing strategies, maintenance, and security considerations
- docs/api-reference.md: Complete API reference documenting CLI, library API
(parse, generate, CodeGenConfig), AST types, error types, and generated
code API with integration guidance for synta runtime
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-23 23:26:24 +02:00
|
|
|
## See Also
|
|
|
|
|
|
synta-codegen: rewrite documentation based on code audit
Add three new reference documents derived from a direct audit of
the parser and code generator source (11 files, ~15,000 lines):
- docs/asn1-support.md: authoritative ASN.1 syntax support matrix.
Covers all parsed constructs, what generates C code, what generates
Rust code, and what is silently dropped vs. causes a parse error.
- docs/rust-generation.md: Rust code generation in depth. Type
mappings, naming conventions, constraint validation in new()
constructors (value range, SIZE, FROM, PATTERN, CONTAINING,
union/intersection/complement, named bits), OPTIONAL/DEFAULT
handling, tagged fields, import modes, no_std, build.rs, library API.
- docs/c-generation.md: C code generation in depth. Type mappings,
generated function signatures, full libcsynta API reference (~40
functions with exact C signatures), memory contract, error handling,
OPTIONAL field patterns, IMPLICIT/EXPLICIT tag handling, CHOICE
dispatch, arena mode, helper functions, CMake/Meson integration.
Fix inaccuracies in existing docs:
- limitations.md: remove false claims. Circular dependency detection
IS implemented (detect_cycles() with DFS). Topological ordering IS
automatic (topological_order()). Rewrite to accurately list what is
not supported: multiple modules per file, parameterized types,
CLASS/WITH SYNTAX, EXPLICIT on anonymous inline types in C backend.
- api-reference.md: remove non-existent CodeGenConfig builder methods
(with_crate_imports, with_super_imports, with_custom_prefix). Document
actual API: CodeGenConfig { import_mode: ImportMode, use_core: bool }.
Fix --custom-prefix flag (actual: --module-prefix). Add --use-core.
Fix generate() return type.
- usage.md: replace stale CodeGenConfig builder method calls with
actual struct literal API. Add --use-core. Add no_std example.
Fix build.rs example to use ImportMode enum.
- multifile.md: fix CodeGenConfig builder method calls throughout.
Update best practices: topological ordering is now automatic.
Update index and pointers:
- docs/README.md: add new files to index with descriptions. Add
navigation by use case section.
- README.md: add asn1-support.md, rust-generation.md, c-generation.md
to documentation section. Point C generation to docs/c-generation.md.
- README_C_GENERATION.md: replace 330-line stale doc with redirect.
- constraints.md, features.md: add pointers to canonical new docs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-02-27 16:27:10 +02:00
|
|
|
- [rust-generation.md](rust-generation.md) -- Rust code generation details, build.rs integration, multi-module projects
|
|
|
|
|
- [c-generation.md](c-generation.md) -- C code generation details, libcsynta API, multi-module projects
|
|
|
|
|
- [asn1-support.md](asn1-support.md) -- supported ASN.1 syntax reference
|