File mttroot/mtt/bin/trans/lbl_txt2tex artifact b15ec7c7b3 part of check-in b1b80ff2c0


#! /bin/sh

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

# Bourne shell script: lbl_txt2tex
# Latex summary of the lbl file

# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  1999/02/17 21:42:19  peterg
## Replaced print by printf to avoid extra nl in paragraph command.
##
## Revision 1.7  1998/07/27 12:56:26  peterg
## Splits up | separated expressions.
##
## Revision 1.6  1998/07/27 10:56:31  peterg
## Cosmetics.
##
## Revision 1.5  1998/07/27 08:29:44  peterg
## Include a comment field in the aliases
##
## Revision 1.4  1998/07/17 19:46:44  peterg
## Included component alias.
##
## Revision 1.3  1998/07/16 20:39:52  peterg
## More cosmetic changes
##
## Revision 1.2  1998/07/16 16:34:09  peterg
## Cosmetic changes
##
## Revision 1.1  1998/07/16 16:31:47  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_lbl.tex

#Create the alias file complete with headers.
echo "% Label summary file ($1_lbl.tex)" > $1_lbl.tex
echo "% Generated by MTT at `date`" >> $1_lbl.tex

#Write out the Description
    grep '[%|#]SUMMARY' $1_lbl.txt | sed 's/_/\\_/g'  |\
    awk '{
           printf("\\paragraph{System %s:",$2);
           for (i=3;i<=NF;i++) printf("%s ",$i); print ""
           print  "}"
         }' >> $1_lbl.tex
    grep '[%|#]DESCRIPTION' $1_lbl.txt | sed 's/_/\\_/g'  |\
    awk '{
           for (i=2;i<=NF;i++) printf("%s ",$i); print ""
         }' >> $1_lbl.tex

#Write out the aliases
cat <<EOF >> $1_lbl.tex
\paragraph{Interface information:}
\begin{description}
EOF
    grep '[%|#]ALIAS' $1_lbl.txt | sed 's/_/\\_/g' |\
    awk '{
      N=split($2,a,"|");
      for (i=1;i<=N;i++){
        if (match(a[i],"\\$")>0){
          printf("\\item [Parameter \\%s] represents actual parameter ",a[i])
        }
        else if (match($3,"/")>0){
          printf("\\item [Component %s]  is in library ",a[i])
        }
        else{
          printf("\\item [Port %s] represents actual port ",a[i])
        }
        printf("\\textbf{%s}",$3)
        if (match($4,"[\#\%]")==1) printf(" -- ");
        for (j=5;j<=NF;j++) printf(" %s", $j)
        printf("\n");
        }
      }
    END{if (NR==0) print "\\item This component has no ALIAS declarations"
}'  | sort >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF

#Write out the VARS
cat <<EOF >> $1_lbl.tex
\paragraph{Variable declarations:}
\begin{description}
EOF
    grep '[%|#][V|P]AR' $1_lbl.txt | sed 's/_/\\_/g' |\
    awk '{
        printf("\\item %s\n",$2)
      }
    END{if (NR==0) print "\\item This component has no PAR declarations"
}'  | sort >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF


#Write out the UNITS
cat <<EOF >> $1_lbl.tex
\paragraph{Units declarations:}
\begin{description}
EOF
    grep '[%|#]UNITS' $1_lbl.txt | sed 's/_/\\_/g' |\
    awk '{
        printf("\\item [Port %s] has domain %s\n",$2, $3)
	printf("\\begin{description}\n")
        printf("\\item [Effort units] %s\n",$4)
        printf("\\item [Flow units] %s\n",$5)
	printf("\\end{description}\n")
      }
    END{if (NR==0) print "\\item This component has no UNITs declarations"
}' >> $1_lbl.tex
cat <<EOF >> $1_lbl.tex
\end{description}
EOF











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