Kaitai Struct Compiler for Elixir.

Compiles .ksy files into Elixir modules that can parse binary data.

Summary

Functions

Compile a .ksy file into an Elixir source code string.

Compile a .ksy file and load the resulting module into the VM. Returns {:ok, module_atom} on success.

Compile a KSY YAML string and load the resulting module.

Compile one or more .ksy files and write each top-level module as a separate .ex file.

Functions

compile(ksy_path, opts \\ [])

Compile a .ksy file into an Elixir source code string.

Options:

  • :namespace — module namespace prefix to apply to all generated modules

compile_and_load(ksy_path, opts \\ [])

Compile a .ksy file and load the resulting module into the VM. Returns {:ok, module_atom} on success.

Options:

  • :namespace — module namespace prefix to apply to all generated modules

compile_string_and_load(yaml_string, opts \\ [])

Compile a KSY YAML string and load the resulting module.

Options:

  • :namespace — module namespace prefix to apply to the generated module

compile_to_files(input_path, output_dir, opts \\ [])

Compile one or more .ksy files and write each top-level module as a separate .ex file.

  • input_path — a single .ksy file or a directory containing .ksy files
  • output_dir — directory where .ex files are written (created if it doesn't exist)
  • opts — keyword list of options:
    • :namespace — module namespace prefix (default: "Ksc.Compiled")

Returns {:ok, [written_file_paths]} or {:error, reason}.