%backend xerces-sax
%language c++
%gen_data parameters.mm variable.mm config.mm

%{
  //C++ code here
  using namespace Data;
%}

%type	Config*		conf
%type	Parameters*	parameters
%type	Variable*	variable

start : conf

conf[1] : parameters variable

parameters[1] : 
@read@
	{
	  $$ = new Parameters(); // Build Parameters object
	  $$->set_param1(marmot::toFloat(@param1@));
	  $$->set_param2(marmot::toBool(@param2@));
	  $$->set_param3(marmot::toInt(@param3@));
	  $$->set_param4(@param4@);
	}
@write@
	{
	  $$ = $father->get_parameters(); // Get Parameters object
	  @param1@ = marmot::toString($$->get_param1());
	  @param2@ = marmot::toString($$->get_param2());
	  @param3@ = marmot::toString($$->get_param3());
	  @param4@ = $$->get_param4();
	}

variable[*] : subvar
@read@
	{
	  $$ = new Variable(); // Build Variable object;
	  $$->set_name(@name@);
	  $$->set_val(marmot::toInt(@val@));
	  $father->add_vars($$);
	}

@write@
@for(std::list::const_iterator it = $father.get_vars().begin();
     it != $father.get_vars().end(); ++it)@
	{
	  $$ = *it; // Get Variable object
	  @name@ = $$->get_name();
	  @val@ = marmot::toString($$->get_val());
	}

subvar[*] :
@read@
	{
	  $father->add_subvars(marmot::toInt($data));
	}

@write@
@for (unsigned int i =0; i < $father->get_subvars().size(); i++)@
	{
	  $data = $father->get_subvars(i);
	}
