Marmot Specifications
1. Data class generator specifications
This Marmot File is constitued of 3 parts :
1.1 Options
%class name : where name represents the Class name to generate%herit father : class name herit from father
%namespace father : give class namespace (for example : Test::Marmot)
%language name : name can be one one the following : c++/java/eiffel
%debug : when given, marmot give a verbose output
%assert : add assert on vector and list (check bounds)
%template <details> : details represents the template type, for example %template <Type, Type2>
1.2 C++/Java/... user code
this code is added to generated file, it can contains include, methods, variables...1.3 Class Variable
you can add severals kind of variable :%var type name(init_val) : type represents the varible type (int, float, std::string, ...)
This will generate a protected variable (type _name) and three public methods (example for C++) :
%var_list type name : type represents the list type (int, float, std::string, ...)
This will generate a protected variable (std::list
%var_vect type name : type represents the vector type (int, float, std::string, ...)
This will generate a protected variable (std::vector
2. XML parser generator specifications
This Marmot File is constitued of 3 parts :2.1 Options
%backend type : where type can be one of the following : (xerces-dom, xerces-sax, expat, libxml)%dtd "file" : file represent a dtd file for xml check
%gen_data file1 file2 : file1 and file2 are data file to generate, this does not need to lauch Marmot many times
%language name : name can be one one the following : c++/java/eiffel
%debug : output verbose information
2.2 C++/Java/... user code
this code is added to generated file, it can contains include, methods, variables...2.3 XML parser details
A Marmot file has four main sections, show here with the appropriate delimiters:
OPTIONS
%{
PROLOGUE
%}
TYPES
XML RULES
Comments enclosed in `/* ... */' may appear in any of the sections.
2.3.1 PROLOGUE
The PROLOGUE section contains macro definitions and declarations of functions and variables that are used in the actions in the XML rules. These are copied to the beginning of the parser file so that they precede the definition of rules. You can use `#include' to get the declarations from a header file. If you don't need any C declarations, you may omit the `%{' and `%}' delimiters that bracket this section.2.3.2 TYPES
The TYPES section contains node type. In some simple xml rules, you may not need any declarations.Synthax of Type is :
%type type_name node_name
2.3.3 XML RULES
A XML rule has the following general form:
result{1} : components ...
@read@
{ code statements }
@write@
{ code statements }
where result is the name of the node, and components are various sub nodes
name that are associates with this node.{a} is the number of node 'result' than can be found as child of a father.
'a' can contains symbols : '>', '<', '>=', '<=', '||', '&&'
For example '{5 || 10}', '{>=2}', '{<=10}'
sometimes, write blocs need a loop (many node to write), you can add a loop between the '@write@' and the '{', For example :
example_node:
@write@
@for(unsigned int i = 0; i < $father->get_vars().size(); i++)@
{
//Code in this loop
}
2.3.3.1 Read/Write node data and attributs
you can read/write atrtibut of a node with @attribut_name@you can read/write node data with $data
you can use father node (when there is a %type on father) with $father
you can call Method of objet associted with current node with $$