Differences From Artifact [f978d62200]:

To Artifact [ff580b61c9]:


8
9
10
11
12
13
14



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

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



# Revision 1.19  1997/03/19  09:49:39  peterg
# Ports now written in cmp file.
#
# Revision 1.18  1997/03/19  09:42:08  peterg
# Now writes out the following additional fig  files:
# _head.fig	The fig header
# _bnd.fig	The bonds actually used







>
>
>







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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.20  1997/03/19 12:02:01  peterg
## Now writes an error message if a lable is used twice in the fig file.
##
# Revision 1.19  1997/03/19  09:49:39  peterg
# Ports now written in cmp file.
#
# Revision 1.18  1997/03/19  09:42:08  peterg
# Now writes out the following additional fig  files:
# _head.fig	The fig header
# _bnd.fig	The bonds actually used
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

184
185
186
187
188
189
190
  for (i=15; i<=NF; i++) {
    str = sprintf("%s %s", str, $i)
      }

# The depth is field 4
  depth = $4; 

# It is terminated by /001 - so delete this termination
  str = substr(str,1,length(str)-4);

# A component string contains only alphanumeric  _ and :
  isa_plain_component = match(str, component_regexp)==0;
# It must also be specified at depth 0
  isa_plain_component = isa_plain_component && (depth==0);

# A port is an integer within [] and no alpha characters
  isa_port = (match(str, port_regexp)>0)&&(match(str, nonport_regexp)==0);

# It must also be specified at depth 0
  isa_port = isa_port && (depth==0);

# A port component is SS followed by : followed by a port string
  isa_port_component = 0;
  if (match(str, delimiter)) {
    split(str,a,delimiter);







|







|
|
>







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
  for (i=15; i<=NF; i++) {
    str = sprintf("%s %s", str, $i)
      }

# The depth is field 4
  depth = $4; 

# It is terminated by \001 - so delete this termination
  str = substr(str,1,length(str)-4);

# A component string contains only alphanumeric  _ and :
  isa_plain_component = match(str, component_regexp)==0;
# It must also be specified at depth 0
  isa_plain_component = isa_plain_component && (depth==0);

# A port is a string within []
  isa_port = (match(str, port_regexp)>0)

# It must also be specified at depth 0
  isa_port = isa_port && (depth==0);

# A port component is SS followed by : followed by a port string
  isa_port_component = 0;
  if (match(str, delimiter)) {
    split(str,a,delimiter);
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
# Coordinates in fields 12 & 13
  x_coord = $12;
  y_coord = $13;

# Do the ports
  if (isa_port) {
    i_port++;
    port_index = substr(str,2,length(str)-2);
    ports[i_port] = sprintf("%s %s %s", x_coord, y_coord, port_index);
  }

# Do the port components
  if (isa_port_component) {
    i_port_component++;
    # Port number is the bit between the []
    port_number  = substr(a[2],2,length(a[2])-2);
    x_port[port_number] = x_coord;
    y_port[port_number] = y_coord;
    info_port[port_number] = fig_info();

  }

# Do the plain components
  if (isa_plain_component) {
    i_text++;

# Get repetitions (if any)







|
|






|
|
|
|
>







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
# Coordinates in fields 12 & 13
  x_coord = $12;
  y_coord = $13;

# Do the ports
  if (isa_port) {
    i_port++;
    port_name = str;
    ports[i_port] = sprintf("%s %s %s", x_coord, y_coord, port_name);
  }

# Do the port components
  if (isa_port_component) {
    i_port_component++;
    # Port number is the bit between the []
    port_label  = substr(a[2],2,length(a[2])-2);
    x_port[i_port_component] = x_coord;
    y_port[i_port_component] = y_coord;
    info_port[i_port_component] = fig_info();
    port_labels[i_port_component] = port_label;
  }

# Do the plain components
  if (isa_plain_component) {
    i_text++;

# Get repetitions (if any)
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
  default_args = "";
  delimiter = ":";
  repetition_delimiter = "*";
  repetition_regexp = "\\*";
  q = "\047";
  terminator = "\\001";
  component_regexp = "[^0-9a-zA-Z_:\*-]";
  port_regexp = "\[[0-9]*\]";
  nonport_regexp = "[a-zA-Z]";
    
  isa_fig_file = 0;
  min_line_length = 10;
  object = 0;
  polyline = 2;
  sub_polyline=1; 







|







474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
  default_args = "";
  delimiter = ":";
  repetition_delimiter = "*";
  repetition_regexp = "\\*";
  q = "\047";
  terminator = "\\001";
  component_regexp = "[^0-9a-zA-Z_:\*-]";
  port_regexp = "^\[[a-zA-Z0-9]*\]";
  nonport_regexp = "[a-zA-Z]";
    
  isa_fig_file = 0;
  min_line_length = 10;
  object = 0;
  polyline = 2;
  sub_polyline=1; 
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
  else {
    process_fig()
      }
}

END {
#Print out the matlab functions
  printf("function [rbonds, rstrokes,rcomponents,rports,n_ports] = %s_rbg\n", sys_name) > b_file;
  printf("%% [rbonds,rstrokes,rcomponents,rports,n_ports] = %s_rbg\n", sys_name) > b_file;
  printf("%% Generated by MTT\n\n") > b_file;

  printf("function [comp_type, name, cr, arg, repetitions] = %s_cmp(i)\n",\
		 sys_name) > c_file;
  printf("%% [comp_type, name, cr, arg, repetitions] = %s_cmp\n", sys_name) > c_file;
  printf("%% Generated by MTT\n\n") > c_file;








|
|







514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
  else {
    process_fig()
      }
}

END {
#Print out the matlab functions
  printf("function [rbonds, rstrokes,rcomponents,port_coord,port_name,port_list] = %s_rbg\n", sys_name) > b_file;
  printf("%% [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = %s_rbg\n", sys_name) > b_file;
  printf("%% Generated by MTT\n\n") > b_file;

  printf("function [comp_type, name, cr, arg, repetitions] = %s_cmp(i)\n",\
		 sys_name) > c_file;
  printf("%% [comp_type, name, cr, arg, repetitions] = %s_cmp\n", sys_name) > c_file;
  printf("%% Generated by MTT\n\n") > c_file;

534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
    print  strokes[i] >> b_file;
  printf("];\n") >> b_file;

  printf("rcomponents = [") >> b_file;
  j = 0;


# Do the port components, in order, first
  for (i = 1; i <= i_port_component; i++) {
    port_type = "SS";
    name = sprintf("[%1.0f]", i);
    cr   = "MTT_port";
    arg  = i;

    if (length(x_port[i])==0)
      printf(warning_p);
    else {
      j++;







|


|







539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
    print  strokes[i] >> b_file;
  printf("];\n") >> b_file;

  printf("rcomponents = [") >> b_file;
  j = 0;


# Do the port components, in order of appearance, first
  for (i = 1; i <= i_port_component; i++) {
    port_type = "SS";
    name = sprintf("[%s]", port_labels[i]);
    cr   = "MTT_port";
    arg  = i;

    if (length(x_port[i])==0)
      printf(warning_p);
    else {
      j++;
579
580
581
582
583
584
585
586
587
588
589


590
591


592
593
594

595






596
597
598
599
      printf("\targ = %s%s%s;\n", q, arg, q) >> c_file;
      printf("\trepetitions = %s;\n",  reps[name]) >> c_file;
      print "end" >> c_file
	}
  }
  printf("];\n") >> b_file;

# Print the ports list
  printf("rports = [\n") >> b_file;
  for (i = 1; i <= i_port; i++)
    print  ports[i] >> b_file;


  printf("];\n\n") >> b_file;



# Print the number of ports
  printf("n_ports = %1.0f;\n", i_port_component) >> b_file;


  







}









|
|
|
|
>
>


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



584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
      printf("\targ = %s%s%s;\n", q, arg, q) >> c_file;
      printf("\trepetitions = %s;\n",  reps[name]) >> c_file;
      print "end" >> c_file
	}
  }
  printf("];\n") >> b_file;

# Print the (internal) ports list
  printf("port_coord = [\n") >> b_file;
  for (i = 1; i <= i_port; i++) {
    split(ports[i],a, " ");
    printf("%s %s\n", a[1], a[2]) >> b_file;
  }
  printf("];\n\n") >> b_file;

  printf("port_name = [\n") >> b_file;
  for (i = 1; i <= i_port; i++) {
    split(ports[i],a, " ");
    printf("'%s'\n", a[3]) >> b_file;
  }
  printf("];\n\n") >> b_file;

# Print the (external) port list
#  printf("n_ports = %1.0f;\n", i_port_component) >> b_file;
  printf("port_list = [\n") >> b_file;
  for (i = 1; i <= i_port_component; i++) 
    printf("'[%s]'\n", port_labels[i]) >> b_file;
  printf("];\n\n") >> b_file;
  
}



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