Differences From Artifact [4ac80571a4]:

To Artifact [d083375b70]:


10
11
12
13
14
15
16




17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$




## Revision 1.1  2000/12/27 15:57:31  peterg
## Initial revision
##
## Revision 1.15  2000/04/06 10:57:12  peterg
## Removed debug line
##
## Revision 1.14  2000/04/06 10:51:14  peterg







>
>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.1  2000/12/27 15:57:31  peterg
## Initial revision
##
## Revision 1.15  2000/04/06 10:57:12  peterg
## Removed debug line
##
## Revision 1.14  2000/04/06 10:51:14  peterg
63
64
65
66
67
68
69




70
71
72
73
74
75
76
##
# Revision 1.1  1996/08/18  20:00:38  peter
# Initial revision
#
###############################################################

documenttype=$2; 





if [  "$documenttype" = "book" ]; then # do book version
  # Inform user
  echo "Creating $1_rep.tex (directory version)"
  strip_comments < $1_rep.txt|\
  gawk '
BEGIN{







>
>
>
>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
##
# Revision 1.1  1996/08/18  20:00:38  peter
# Initial revision
#
###############################################################

documenttype=$2; 
mtt_switches=$4

## Remove -u and -q
mtt_switches=`echo ${mtt_switches} | sed 's/-[qu]//g'`

if [  "$documenttype" = "book" ]; then # do book version
  # Inform user
  echo "Creating $1_rep.tex (directory version)"
  strip_comments < $1_rep.txt|\
  gawk '
BEGIN{
107
108
109
110
111
112
113



114

115
116
117



118



119




120












121
122
123
124
125
126
127
# Inform user
echo "Creating $1_rep.tex"

# Create the LaTeX file
strip_comments <$1_rep.txt |\
gawk '
{



  ## Count the switches (noting that -i has an argument)

  Switches=0;
  for (i=2;i<=NF;i++) {
    if (match($i,"-")==1) Switches++;



    if (match($i,"-i")==1) Switches++;



  }

















  System = $(Switches+2)
  Representation = $(Switches+3);
  Multiple = "odes odeso sms smso daes daeso";
  Language = $(Switches+4);
  Languages = "tex txt r m c h ps icad";
  args = $(Switches+5);
  quote = "\047";







>
>
>
|
>
|

|
>
>
>
|
>
>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Inform user
echo "Creating $1_rep.tex"

# Create the LaTeX file
strip_comments <$1_rep.txt |\
gawk '
{
  ## Add in the external switches
  sub("mtt", sprintf("mtt %s", mtt_switches));
  
  ## Count the switches (noting that -i -dr -dw and -de have an argument)
  ## and make up a string (switches) containing them
  Switches=0; switches = "";
  for (i=2;i<=NF;i++) {
    if (match($i,"-")==1) {
      Switches++;
      switches=sprintf("%s%s", switches, $i);
    }
    if (match($i,"-i")==1) {
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dr")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-dw")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
    if (match($i,"-de")==1){
      Switches++;
      j=i+1;
      switches=sprintf("%s%s", switches, $j);
    }
  }
  print "%%%" switches
  System = $(Switches+2)
  Representation = $(Switches+3);
  Multiple = "odes odeso sms smso daes daeso";
  Language = $(Switches+4);
  Languages = "tex txt r m c h ps icad";
  args = $(Switches+5);
  quote = "\047";
136
137
138
139
140
141
142
















143
144
145

146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
  }
  else
  {
  _Args = "";
  __Args = "";
  ___Args = "";
  }
















#  print "DEBUG", Language, args, _Args, __Args
  RepLang = sprintf("%s%s.%s", Representation, __Args, Language);
  SysRepLang = sprintf("%s_%s", System, RepLang);

  SysRep = sprintf("%s_%s%s", System, Representation, _Args);
  filename = gensub(/,/, "-", "g", SysRep);
  section_head = sprintf("\\textbf{%s.%s}: System %s, representation \\textbf{%s%s}, language \\textbf{%s}",
   Representation,Language,System,Representation,__Args,Language);
   
# section headings
    if (match(Languages,Language)>0) {
    print "\n\n\\section{" section_head "}";
    print "\\label{sec:" SysRepLang "}";
    print "\\index{\\textbf{" System "} -- " Representation "}";
    
    print "\n\nMTT command:";
    print "\\begin{verbatim}";
      for (i=1;i<=NF;i++) printf("%s ", $i);
    print "\n\\end{verbatim}";
    }

# tex files
    if( match("tex",Language)>0) {
      printf("  \\input{%s/%s_%s.%s}\n", PWD, System, Representation, Language);
#      command = sprintf("sed s!fig{!fig{%s! < %s_%s.%s", Directory, System, Representation, Language);
#      system(command);    
}

# text files
    if( match("txt r m c h icad",Language)>0) {
      print "  \\begin{verbatim}";
      command = sprintf("cat %s_%s.%s", System, Representation, Language);
      system(command);
      print "  \\end{verbatim}";  
    }
# ps files
    if( match("ps",Language)>0) {
      printf("This representation is given as Figure \\Ref{fig:%s}.\n", SysRepLang);
      FileName = sprintf("%s/%s", PWD, filename);
      Label = sprintf("%s", SysRepLang);
      Caption = sprintf("System \\textbf{%s}, representation %s%s", System, Representation, __Args);
      printf("\\fig{%s}\n    {%s}\n    {0.9}\n    {%s}\n",FileName,Label,Caption);
  }
}
END {

}' system=$1 Directory=$directory PWD=`pwd` > $1_rep.tex

fi














>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



>
|

|
|




|


















|





|

|
|





|


<
<
<
<
<
<
<
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241







  }
  else
  {
  _Args = "";
  __Args = "";
  ___Args = "";
  }

  ## Add in the mtt args
  __Args = sprintf("%s%s", switches, __Args);

  ## Treat no arguments as -noargs
  if (length(__Args)==0){
    __Args = "-noargs";
    header_args = "";
  }
  else {
    header_args = __Args;
    gsub("-", " -", header_args);
    header_args = sprintf("(%s)", header_args); 
  }

print "%%" __Args "%%"
#  print "DEBUG", Language, args, _Args, __Args
  RepLang = sprintf("%s%s.%s", Representation, __Args, Language);
  SysRepLang = sprintf("%s_%s", System, RepLang);
  SysRepLangArgs = sprintf("%s_%s", System, RepLang, __Args);
  SysRep = sprintf("%s_%s%s", System, Representation, __Args);
  filename = gensub(/,/, "-", "g", SysRep);
  section_head = sprintf("\\textbf{%s\\_%s.%s} \\emph{%s}",
   System,Representation,Language, header_args);
   
# section headings
    if (match(Languages,Language)>0) {
    print "\n\n\\section{" section_head "}";
    print "\\label{sec:" SysRepLangArgs "}";
    print "\\index{\\textbf{" System "} -- " Representation "}";
    
    print "\n\nMTT command:";
    print "\\begin{verbatim}";
      for (i=1;i<=NF;i++) printf("%s ", $i);
    print "\n\\end{verbatim}";
    }

# tex files
    if( match("tex",Language)>0) {
      printf("  \\input{%s/%s_%s.%s}\n", PWD, System, Representation, Language);
#      command = sprintf("sed s!fig{!fig{%s! < %s_%s.%s", Directory, System, Representation, Language);
#      system(command);    
}

# text files
    if( match("txt r m c h icad",Language)>0) {
      print "  \\begin{verbatim}";
      command = sprintf("cat %s.txt", filename);
      system(command);
      print "  \\end{verbatim}";  
    }
# ps files
    if( match("ps",Language)>0) {
      printf("This representation is given as Figure \\Ref{fig:%s}.\n", SysRepLangArgs);
      FileName = sprintf("%s/%s", PWD, filename);
      Label = sprintf("%s", SysRepLangArgs);
      Caption = sprintf("System \\textbf{%s}, representation %s (%s)", System, Representation, __Args);
      printf("\\fig{%s}\n    {%s}\n    {0.9}\n    {%s}\n",FileName,Label,Caption);
  }
}
END {

}' mtt_switches="${mtt_switches}" system=$1 Directory=$directory PWD=`pwd` > $1_rep.tex

fi








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