File mttroot/mtt/bin/trans/mtt_txt2declare artifact 63bdb9c744 part of check-in 71931bacd1


#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sympar_txt2declare

# Symbolic parameters to variable declaration
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/10/14 09:32:50  peterg
## struc version only does state and input
##
## Revision 1.1  2000/10/14 09:26:48  peterg
## Initial revision
##
## Revision 1.1  2000/10/11 09:08:20  peterg
## Initial revision
##

###############################################################

sys=$1
what=$2
language=$3

case $language in
    p)
        first="VAR";
        delim=", ";
        last=': REAL;';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

case $what in
    struc)
	strip_comments < $sys"_"$what".txt" | gawk '{if (($1=="state")||($1=="input"))
                                                      print $4;
                                                   }' >mtt_names
	;;
    sympar)
      	strip_comments < $sys"_"$what".txt" | gawk '{print $1}' >mtt_names
	;;
    *)
	echo Argument 2 must be struc or sympar
esac

# Start
cat<<EOF
$first
EOF
#Write out the variables 
gawk '{
  i++; 
  var[i] = tolower($1);
}
END{
  n = i;
  for (i=1; i<n; i++){
    printf("%s%s",var[i], delim);
    j++; 
    if (j>4){
    printf("\n"); j=0;
    }
  }
  printf("%s%s\n",var[n], last);

}' "delim=$delim" "last=$last" mtt_names




MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]