Overview
Comment:Parses repetative components: ie suffixed by *n.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: e1c12e184421c6d050a6aa55d605d54756993c7c1df8c337d102bc8ee9c1e283
User & Date: gawthrop@users.sourceforge.net on 1996-08-19 09:03:13
Other Links: branch diff | manifest | tags
Context
1996-08-19
09:03:41
Handles repeating components. check-in: 9ceaa5943a user: gawthrop@users.sourceforge.net tags: origin/master, trunk
09:03:13
Parses repetative components: ie suffixed by *n. check-in: e1c12e1844 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
09:02:12
Errors go to user - not log. check-in: 9c79bcf917 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/awk/rbg_fig2m.awk from [dcf5ac5f4d] to [0595e9c3fe].

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.8  1996/08/05 20:12:43  peter
## Now writes a _fig.fig file.
##
## Revision 1.7  1996/08/05 18:44:56  peter
## Now writes out a _cbg file without ----- symbol.
##
## Revision 1.6  1996/08/05 12:17:37  peter







>
>
>







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.9  1996/08/09 08:23:11  peter
## Fixed bug: ports not recognised.
##
## Revision 1.8  1996/08/05 20:12:43  peter
## Now writes a _fig.fig file.
##
## Revision 1.7  1996/08/05 18:44:56  peter
## Now writes out a _cbg file without ----- symbol.
##
## Revision 1.6  1996/08/05 12:17:37  peter
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  str = $14; 
  for (i=15; i<=NF; i++) {
    str = sprintf("%s %s", str, $i)
      }
# It is terminated by /001 - so delete this termination
  str = substr(str,1,length(str)-4);

# A component string contain only alphanumeric  _ and :
  isa_plain_component = match(str, component_regexp)==0;

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

# A port component is SS followed by : followed by a port string
  isa_port_component = 0;







|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
  str = $14; 
  for (i=15; i<=NF; i++) {
    str = sprintf("%s %s", str, $i)
      }
# 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;

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

# A port component is SS followed by : followed by a port string
  isa_port_component = 0;
161
162
163
164
165
166
167










168
169
170
171
172
173
174
    y_port[port_number] = y_coord;
    info_port[port_number] = fig_info();
  }

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











    named_component = (match(str,delimiter) > 0);
    if (named_component) {
      split(str,a,delimiter);
      type = a[1];
      name = a[2];








>
>
>
>
>
>
>
>
>
>







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
    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)
    if (match(str,repetition_regexp) > 0) {
      split(str,b,repetition_delimiter);
      repetitions = b[2];
      str = b[1];
	}
    else {
      repetitions = "1";
    };

    named_component = (match(str,delimiter) > 0);
    if (named_component) {
      split(str,a,delimiter);
      type = a[1];
      name = a[2];

225
226
227
228
229
230
231

232
233
234
235
236
237
238
	}

# Save in associative arrays by name	
    comp_type[name] = type;
    x[name] = x_coord;
    y[name] = y_coord;
    info[name] =  fig_info();

  }

}

function process_bond() {

  arg_count++;







>







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
	}

# Save in associative arrays by name	
    comp_type[name] = type;
    x[name] = x_coord;
    y[name] = y_coord;
    info[name] =  fig_info();
    reps[name] = repetitions;
  }

}

function process_bond() {

  arg_count++;
323
324
325
326
327
328
329


330
331
332
333
334
335
336
337
338
339
  warning_p = "WARNING system ports are not consecutively numbered\n";

  data_symbol = "----";
  out_data_symbol = "\t";
  default_cr = "";
  default_args = "";
  delimiter = ":";


  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;







>
>


|







337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
  warning_p = "WARNING system ports are not consecutively numbered\n";

  data_symbol = "----";
  out_data_symbol = "\t";
  default_cr = "";
  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;
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386

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] = %s_cmp(i)\n",\
		 sys_name) > c_file;
  printf("%% [comp_type, name, cr, arg] = %s_cmp\n", sys_name) > c_file;
  printf("%% Generated by MTT\n\n") > c_file;

  printf("rbonds = [\n") >> b_file;
  for (i = 1; i <= i_bond; i++)
    print  bonds[i] >> b_file;
  for (i = 1; i <= i_arrow; i++)
    print  arrows[i], "-1 -1" >> b_file;







|

|







386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402

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;

  printf("rbonds = [\n") >> b_file;
  for (i = 1; i <= i_bond; i++)
    print  bonds[i] >> b_file;
  for (i = 1; i <= i_arrow; i++)
    print  arrows[i], "-1 -1" >> b_file;
429
430
431
432
433
434
435

436
437
438
439
440
441
442
      j++;
      print x[name], y[name], info[name] >> b_file;
      printf("if i==%1.0f\n", j) 	>> c_file;
      printf("\tcomp_type = %s%s%s;\n", q, comp_type[name], q) >> c_file;
      printf("\tname = %s%s%s;\n", q, name, q) >> c_file;
      printf("\tcr = %s%s%s;\n", q, cr, q) >> c_file;
      printf("\targ = %s%s%s;\n", q, arg, q) >> c_file;

      print "end" >> c_file
	}
  }
  printf("];\n") >> b_file;

# Print the ports list
  printf("rports = [\n") >> b_file;







>







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
      j++;
      print x[name], y[name], info[name] >> b_file;
      printf("if i==%1.0f\n", j) 	>> c_file;
      printf("\tcomp_type = %s%s%s;\n", q, comp_type[name], q) >> c_file;
      printf("\tname = %s%s%s;\n", q, name, q) >> c_file;
      printf("\tcr = %s%s%s;\n", q, cr, q) >> c_file;
      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;


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