Skip to main content
Version: Current

Validate and Compile

CradleXC provides separate commands for validating CRADLE source and compiling it into structured output.

The typical workflow is:

CRADLE source
↓
Validate syntax
↓
Compile scenario
↓
Generated YAML

Validation should normally be performed before compilation so syntax problems can be identified early.

Validate a scenario​

Pass the scenario path to cxc validate with -i. For the Hello World example, run:

cxc validate -i scenarios/HelloWorld.cradle

If the scenario is valid, CradleXC prints a checkmark and a short summary.

Show the successful validation result
✓ scenarios/HelloWorld.cradle is valid
instances: 2
networks: 1
events: 1 (pre=0, main=1, post=0)
objects: 1

The first line confirms that validation succeeded. The remaining lines count the scenario elements CradleXC found:

ResultMeaning
instances: 2Two machines: win7 and router.
networks: 1One network: lan_0.
events: 1 (pre=0, main=1, post=0)One main event and no events in the other phases.
objects: 1One declared object: HelloWorld.

You can proceed to compilation after seeing a valid result. If validation fails, CradleXC prints diagnostics identifying the source that needs to be corrected.

note

Validation checks the CRADLE source before target-specific backend generation. A backend plugin is not required to validate a scenario.

Fix validation errors​

If validation fails, review the diagnostics returned by CradleXC.

The reported information can help identify problems such as:

  • malformed CRADLE syntax
  • incomplete declarations
  • incorrectly structured statements
  • unexpected values or tokens

Correct the relevant .cradle source and run validation again:

cxc validate -i scenarios/HelloWorld.cradle

Repeat this process until the scenario validates successfully.

For broader troubleshooting guidance, see Troubleshooting.

Compile a scenario​

Once validation succeeds, compile the scenario with cxc compile.

cxc compile \
-i <scenario.cradle> \
-o <output.yml>

For the Hello World scenario:

cxc compile \
-i scenarios/HelloWorld.cradle \
-o HelloWorld.yml

CradleXC processes the CRADLE source and writes the compiled representation to the specified YAML file.

The resulting file in this example is:

HelloWorld.yml

Input and output​

The two main arguments used during compilation are:

ArgumentPurpose
-iSpecifies the input .cradle scenario.
-oSpecifies the output YAML file.

For example:

cxc compile \
-i scenarios/HelloWorld.cradle \
-o build/HelloWorld.yml

This reads:

scenarios/HelloWorld.cradle

and writes the compiled output to:

build/HelloWorld.yml
note

Make sure the output directory exists before compiling if you specify a path containing additional directories.

Validate before compiling​

A simple development workflow is:

cxc validate -i scenarios/HelloWorld.cradle
cxc compile -i scenarios/HelloWorld.cradle -o HelloWorld.yml

This keeps validation and compilation as separate steps.

HelloWorld.cradle
↓
cxc validate
↓
cxc compile
↓
HelloWorld.yml

Inspect the intermediate representation​

CradleXC can also display the intermediate representation produced while processing a scenario.

Use:

cxc dump-ir -i <scenario.cradle>

For example:

cxc dump-ir -i scenarios/HelloWorld.cradle

This is useful when you want to inspect how CradleXC interpreted the CRADLE source.

You do not normally need to inspect the intermediate representation for every scenario.

note

cxc dump-ir is primarily an inspection and diagnostic command. It does not replace validation or compilation.

Compilation is not backend generation​

cxc compile generates CradleXC's compiled YAML output.

It does not generate files for a specific backend target.

The workflow can be viewed as:

CRADLE source
↓
CradleXC validation and compilation
↓
Compiled YAML

When target-specific files are required, use a compatible backend plugin separately.

For example:

cxc build \
-i scenarios/HelloWorld.cradle \
--target <plugin_name> \
-o /path/to/output

Backend installation and target-specific generation are covered in Use a Backend.

For normal scenario development:

  1. Write or modify the .cradle source.
  2. Validate the scenario with cxc validate.
  3. Fix any reported syntax errors.
  4. Compile the scenario with cxc compile.
  5. Inspect the generated YAML when required.
  6. Use a backend plugin only when target-specific files are needed.

This keeps CRADLE source validation, compilation and backend generation as distinct stages.

Example workflow​

Starting with:

scenarios/
└── HelloWorld.cradle

Validate the scenario:

cxc validate -i scenarios/HelloWorld.cradle

Compile it:

cxc compile \
-i scenarios/HelloWorld.cradle \
-o HelloWorld.yml

Your files then look like:

.
├── HelloWorld.yml
└── scenarios/
└── HelloWorld.cradle

You can now inspect the generated YAML or continue to backend-specific generation.

Next steps​