Index: mttroot/mtt/bin/trans/awk/rbg_fig2m.awk ================================================================== --- mttroot/mtt/bin/trans/awk/rbg_fig2m.awk +++ mttroot/mtt/bin/trans/awk/rbg_fig2m.awk @@ -10,10 +10,13 @@ ############################################################### ## 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. @@ -122,11 +125,11 @@ 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 : +# 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); @@ -163,10 +166,20 @@ } # 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]; @@ -227,10 +240,11 @@ # 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() { @@ -325,13 +339,15 @@ 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_:]"; + component_regexp = "[^0-9a-zA-Z_:\*]"; port_regexp = "\[[0-9]*\]"; nonport_regexp = "a-zA-Z"; isa_fig_file = 0; min_line_length = 10; @@ -372,13 +388,13 @@ #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",\ + printf("function [comp_type, name, cr, arg, repetitions] = %s_cmp(i)\n",\ sys_name) > c_file; - printf("%% [comp_type, name, cr, arg] = %s_cmp\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; @@ -431,10 +447,11 @@ 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;