Wednesday, February 22, 2017

example11_simple.zubr

I thought I would present the subsequent zubr examples from the "examples" folder in the package perkun. Let us begin with example11_simple.zubr:


// This is an example zubr specification.

%%

// here we put the Perkun code (values and variables)

values {}
variables {}

%%

// here we put Java code to be included in the result class


In the above example we have a legal zubr specification. We begin with a declaration section where we can place for example Java imports. Then we have a separator %% and a Perkun section follows, with two subsections - values and variables. Then we have another separator %% and definition section follows, where we can place the Java code to be included within the result class.

Let us run:
zubr example11_simple.zubr > Optimizer.java

This will produce a Java code. The code will contain an Optimizer class which needs to be instantiated. Then we can run the instance's "loop" method. 

This simple example does not contain any Perkun variables, its purpose is just to demonstrate the zubr concept. Next examples will generate Java code based on the Java Swing package.

Download the zubr tool with the package: https://sourceforge.net/projects/perkun/.


No comments:

Post a Comment