File mttroot/mtt/bin/trans/mtt2reps_txt artifact 38143b0d0c part of check-in c999c510dc


#! /bin/sh

# mtt2reps_txt: Gives a tabular listing of representations and languages
# P J Gawthrop July 1998, October 1998
# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.11  2001/04/28 03:38:36  geraint
## Refined selection of matching patterns - checks for exact match.
##
## Revision 1.10  2000/09/14 07:54:13  peterg
## Removed -e option in echo
##
## Revision 1.9  2000/04/05 08:34:30  peterg
## removed output tab
##
## Revision 1.8  2000/04/05 08:04:01  peterg
## Minor reorganisation
##
## Revision 1.7  2000/04/04 16:15:14  peterg
## Fixed awk prob - must be the same sep. for each field (?)
## So tr tab to space
##
## Revision 1.6  2000/04/04 13:09:51  peterg
## *** empty log message ***
##
## Revision 1.5  2000/01/19 17:26:12  peterg
## Now includes the representation title.
##
## Revision 1.4  1999/03/09 00:03:06  peterg
## Revisions for xmtt
##
## Revision 1.3  1999/03/08 21:24:43  peterg
## Handles * representations:
##
## 	rep* is special
##         rep shows all possible languages
##
## Revision 1.2  1999/03/08 06:34:07  peterg
## Removed mtt help - replaced by grep #SUMMARY - quicker
##
## Revision 1.1  1998/10/20 08:15:08  peterg
## Initial revision
##
###############################################################

sep='|'; # Separates the languages from the rest.

## List of all representations (deleting the *)
representations=`grep '#SUMMARY' $MTTPATH/mtt | awk '{sub("\*","+"); print $2'} | sort -u `


for rep in $representations ; do
    Rep=`echo $rep | tr '+' '*'`
    ## Title should be same for all languages -- but extract the first non-empty version
      title=`grep '#SUMMARY' $MTTPATH/mtt | tr '\t' ' ' | grep "[ *]$Rep[ *]" | \
      awk  '{if (NF>2) {for (i=3;i<NF-1;i++) printf("%s ",$i); NF1=NF-1; printf("%s\n",$NF1)}}' |\
      head -1`
      
    language=`grep '#SUMMARY' $MTTPATH/mtt |\
      awk '
        {
          if (index(rep,"*")==length(rep)){
            if ($2==rep) print $NF
          }
          else
            if (($2==rep)||($2==sprintf("%s*",rep))) print $NF
        }' rep=$Rep |\
      sort -u | sed 's/[()]//g'` 

      Title='('$title')'
      echo "$Rep" $Title  $sep $language
     
done






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