Validate and Compile
CradleXC provides separate commands for validating CRADLE source and compiling it into structured output.
The typical workflow is:
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:
| Result | Meaning |
|---|---|
instances: 2 | Two machines: win7 and router. |
networks: 1 | One network: lan_0. |
events: 1 (pre=0, main=1, post=0) | One main event and no events in the other phases. |
objects: 1 | One 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.
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:
| Argument | Purpose |
|---|---|
-i | Specifies the input .cradle scenario. |
-o | Specifies 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
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.
cxc validatecxc compileInspect 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.
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:
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.
Recommended workflow
For normal scenario development:
- Write or modify the
.cradlesource. - Validate the scenario with
cxc validate. - Fix any reported syntax errors.
- Compile the scenario with
cxc compile. - Inspect the generated YAML when required.
- 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
- Learn how to inspect compiler output.
- Learn how to use a backend plugin to generate target-specific files.
- See Troubleshooting if validation or compilation fails.