Zserio Extension Sample
December 9, 2024 ยท View on GitHub
Sample implementation of Zserio extension.
This extension prints all AST (Abstract Syntax Tree) nodes to the terminal. The extension can be invoked by
command line option -sample.
Example
Using the schema
package simple_structure;
struct SimpleStructure
{
int32 numberA;
uint8 numberB;
string name;
}
gives Zserio compiler together with this Zserio extension sample the following output:
Parsing simple_structure.zs
Calling Sample extension check
Calling Sample extension
package simple_structure
structure SimpleStructure
int32 numberA
uint8 numberB
string name
Done
Prerequisites
- Java SDK
- Apache Ant
- Zserio core (
zserio_core.jar) together with dependent libraries.
Zserio core with dependent libraries will be automatically downloaded from GitHub according to the extension version located in the module
SampleExtension.java.
Build
ant install
Run
java -cp build/download/zserio_libs/zserio_core.jar:distr/zserio_sample.jar \
zserio.tools.ZserioTool simple_structure.zs -sample
To simplify the command for running the extension, ensure that zserio_sample.jar is in the same directory
as zserio_core.jar. Once copied, you can use the following command:
java -jar zserio_core.jar simple_structure.zs -sample
Bundled Zserio
There is a sample implementation of bundled Zserio which will contain all extensions found in the original bundled Zserio together with the extension sample.
Build
ant zserio_bundle.install
Run
java -jar distr/zserio.jar simple_structure.zs -sample