1.1.4. Syntax of HuGo Language
Aus Hugo Doku
As the HuGo syntax in the Frame classes is a Java meta language, there are special signs which look strange when you see it first. This signs are explained in the following subchapters.
Inhaltsverzeichnis |
1.1.4.1. @#
Any HuGo declaration is marked with a beginning @# to distinguish them from normal java code.
The @# is further used for HuGo method calls within a Output Methods. This is important to distinguish a method call, which is generated in the target code, from a HuGo method call, which controls the output, the so called Context Methods.
1.1.4.2. <! ... !>
The <!... !> are the HuGo brackets. They correspond to (...) in normal java.
The <!... !> are as well used within a generating method to access variables.
1.1.4.3. <# ... #>
The <#... #> are the HuGo block brackets. They correspond to {...} in normal java. They are used e.g. at a generating method to mark the beginning an the end of its body. 1.1.4.4. Structure of a Frame class
As the HuGo syntax is a java meta language the structure of a Frame class is very similar to a normal java class.
1.1.4.4.1. Declarations
HuGo declarations are on the same level as normal java declaration as e.g. class member variables. You can declare normal class member variables, special variables, that correspond to the XML attributes set by the model-file, and other special HuGo elements like e.g. slots.
HuGo knows the following declarations:
*Attribute Variables
Attribute variables are used to access the attribute values of the tag belonging to the Frame object.
For detailed information please refer to Chapter Attribute Variables.
*Context Variables (not used in the simple_class example)
Context variables are used to forward variable values to child frame objects. (For details please refer to Chapter Context Variables)
*Declarations of Slots
After declaring a slot, you can use it inside an Output Methods (=@#gen method) to invoke the corresponding @#gen methods of the frame objects children.
For detailed information please refer to Chapter Declaration of Slots.
*Factory objects (not used in the simple_class example)
You can use factory objects to create Frame objects at runtime of the generator process.
For detailed information please refer to Chapter Factory Objects.
1.1.4.4.2. @#gen Methods
@#gen methods are the so called Output Methods. They contain the templated target code, which is generated.
A @#gen method with parameters creates a file on the disk, where the target code is written to.
@#gen methods without parameters are slot methods, they are called by other @#gen methods by using that slotname, e.g. in the figure to simple_class you see the generating method JCLASS, which has the slot @#item_decl. The corresponding method @#gen item_decl is located in the Frame class item.
For a fully description of all possible output methods and their parameters please refer to section Chapter 12..
1.1.4.4.3. @#constructor
The Frame classes are instantiated when the individual generator runs and has read the model file. The model file specifies which Frame classes are instantiated. In Example 1.1 there are two items specified, i.e. there are two exemplaries of the Frame class item. When a Frame object is created, the @#constructor is called analogous to normal Java objects .
For further details on a @#constructor method please refer to Chapter Constructor.
1.1.4.4.4. Normal Java Elements
Keep in mind, that the HuGo language is a Java meta language, i.e. you can use in the Frame class every Java construct, your current Java version supports. Thus you can e.g write any Java methods within your Frame class, use elements of the Java API as hashmaps and use all Java mechanismen like inheritance.
