diff options
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 167 |
1 files changed, 95 insertions, 72 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index cdffa5932cc..350a3e973c5 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.60 Copyright (c) 2013-2021 Akira Yamaji +% mcf2graph ver 4.61 Copyright (c) 2013-2021 Akira Yamaji % % Permission is hereby granted, free of charge, to any person obtaining a copy of this software % and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -37,7 +37,7 @@ % Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; -message "* This is mcf2graph ver 4.60 2021.03.07"; +message "* This is mcf2graph ver 4.61 2021.03.21"; %------------------------------------------------------------------------------------------------- newinternal cntA,cntB,cntM,minX,minY,maxX,maxY,sftX,sftY,com,par,envT,envB,lenT,lineT,angT,rotT, crR,nA,nB,nC,nD,nE,nF,nS,nL,nR,nU,nP,xpos,ypos,markA,markB,saveA,saveB,bondL; @@ -68,7 +68,8 @@ a_prn_s:=ASCII("("); a_prn_e:=ASCII(")"); a_brc_s:=ASCII("{"); a_brc_e:=ASCII("} a_brk_s:=ASCII("["); a_brk_e:=ASCII("]"); a_cmm:=ASCII(","); a_equ:=ASCII("="); a_ast:=ASCII("*"); a_sls:=ASCII("/"); a_gtn:=ASCII("<"); a_ltn:=ASCII(">"); a_and:=ASCII("&"); a_dol:=ASCII("$"); a_hsh:=ASCII("#"); a_hat:=ASCII("^"); a_tld:=ASCII("~"); a_bqt:=ASCII("`"); -a_cln:=ASCII(":"); a_amk:=ASCII("@"); a_zero:=ASCII("0"); a_nine:=ASCII("9"); +a_cln:=ASCII(":"); a_amk:=ASCII("@"); a_zero:=ASCII("0"); a_nine:=ASCII("9"); a_qut:=ASCII("'"); +a_bar:=ASCII("|"); %-------------------------------------------------------------------------------------------------- let DIV= /; let MUL= *; let LT= <; let GT= >; let AND= &; let :: = : ; let == = =; let ef=elseif; def ]]]=] ] ] enddef; @@ -277,7 +278,7 @@ def beginfont(text s)= %------------------------------------------------------------------------------------------------ char_num:=char_num+1; store_par(parameter_list); - f_ext:=cntM:=mc_low:=inf_num:=0; + f_ext:=cntM:=mc_row:=inf_num:=0; for list=s: inf_num:=inf_num+1; info[inf_num]:=list; mc[inf_num]:=""; endfor %------------------------------------------------------------------------------------------------ for j=1 upto inf_num: @@ -287,10 +288,10 @@ def beginfont(text s)= if at_colon=1: s_fw:=0; for k=2 upto s_len: if subc(k,info[j])<>" ": s_fw:=k; fi exitif s_fw>0; endfor s_bw:=0; for k=s_len downto 2: if subc(k,info[j])<>" ": s_bw:=k; fi exitif s_bw>0; endfor - mc_low:=mc_low+1; - mc_indent[mc_low]:=s_fw-2; - mc[mc_low]:=substring (s_fw-1,s_bw) of info[j]; - mc:=mc&mc[mc_low]; + mc_row:=mc_row+1; + mc_indent[mc_row]:=s_fw-2; + mc[mc_row]:=substring (s_fw-1,s_bw) of info[j]; + mc:=mc&mc[mc_row]; ef at_colon>=1: s_tag:=substring (0,at_colon-1) of info[j]; s_var:=substring (at_colon,s_len) of info[j]; @@ -356,15 +357,15 @@ def endfont= enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def set_def_MC= - save /,//,/*,*/,**,*/*,~,^,',`,<,>,&,:,=,\,\\,*\,\*,*\*,@,@@,$,&,#,##,{,},|,||,_,inside_def_MC; + save /,//,/*,*/,**,*/*,~,^,',`,<,>,:,=,\,\\,*\,\*,*\*,@,@$,$,&,&$,#,##,{,},|,||,_,inside_def_MC; inside_def_MC:=1; pair |,||,##; | :=(_com,_mark); || := (_com,_moff); ##:=(_com,_len_e); _:=Me; \:=0; \\:=zero_dm; *\:=zero_wf; \*:=zero_zf; *\*:=zero_wv; let = ==op_equ; let : ==op_col; let ^ ==op_hat; let ~ ==op_til; let > ==op_lt; let ` ==op_bq; - def { == read_number( enddef; let } == ); def '==read_id enddef; + def @$ == @.$ enddef; def { == read_number( enddef; let } == ); def '==read_id enddef; def < == rot_angle enddef; def @ == jump_atom enddef; def & == cyc_atom enddef; - def # == chg_length enddef; def $ == abs_adress enddef; + def # == chg_length enddef; def $ == abs_adress enddef; def &$ == &.$ enddef; def / == group_si enddef; def // == group_dm enddef; def */ == group_wf enddef; def /* == group_zf enddef; def */* == group_wv enddef; def ** == group_nb enddef; enddef; @@ -1578,17 +1579,20 @@ def proc_report_out= out_file_name:=out_file_rep; printf "==========================================================================="; printf " No."&fdr(4)(char_num)&" / Name = "& inf_EN; - if mc_low>=1: + if mc_row>=1: printf "---------------------------------------------------------------------------"; - for i=1 upto mc_low: + for i=1 upto mc_row: printf (substring(0,mc_indent[i]) of blank_str)&mc[i]; endfor printf "---------------------------------------------------------------------------"; - printf " mc-length="&fdr(4)(length(mc))&" / mc-low="&fdr(3)(mc_low)& - " / mc-commands="&fdr(3)(cmm_cnt); + printf " row="&fdr(3)(mc_row)&" / length="&fdr(4)(length(mc))& + " / commands="&fdr(3)(cnt_cmm); + printf " {}=X ="&fdr(3)(cnt_chg_bonds)&" / {}:X ="&fdr(3)(cnt_chg_atoms)& + " / '() ="&fdr(3)(cnt_inline_def)&" / @ ="&fdr(3)(cnt_at)& + " / & ="&fdr(3)(cnt_and)&" / < ="&fdr(3)(cnt_gtn); fi printf "---------------------------------------------------------------------------"; - printf " Warnings = "&fdr(3)(warning_cnt)&" / Command count= "&decimal(cntD[0]); + printf " Warnings = "&fdr(3)(warning_cnt)&" / Code= "&decimal(cntD[0]); printf " Width * Height = " & fdr(10)(mol_wd)&" * "&fdr(10)(mol_ht); printf " Shift width * height = "& fdr(10)(minX)&" * "&fdr(10)(minY); printf " Bond length = "&fdr(3)(blen)&" Atom size = "&fdr(3)(atom_wd); @@ -1799,87 +1803,106 @@ def expand_set= !SH:='(!,SH); !NO2:='(!,NO2); enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -vardef check_mc(expr s)= +vardef check(expr s)= save mc_char,mc_char,temp_c,err_cnt,char_cnt,f_depth, - a_prn_s_cnt,a_prn_e_cnt,a_brc_s_cnt,a_brc_e_cnt,a_brk_s_cnt,a_brk_e_cnt; - f_depth:=cmm_cnt:=0;; + cnt_prn_s,cnt_prn_e,cnt_brc_s,cnt_brc_e,cnt_brk_s,cnt_brk_e; string temp_c,err_str[],err_type[]; numeric mc_char[],err_adr[],err_code[]; - err_cnt:=char_cnt:=code_cnt:=0; + err_cnt:=char_cnt:=code_cnt:=f_depth:=cnt_cmm:=cnt_chg_atoms:=cnt_chg_bonds:=0; + err_type[0]:="no mc-row "; err_type[1]:=" '(' > ')' "; err_type[2]:=" '(' < ')' "; err_type[3]:=" '{' > '}' "; err_type[4]:=" '{' < '}' "; err_type[5]:=" '[' > ']' "; err_type[6]:=" '[' < ']' "; err_type[7]:="missing arg"; err_type[8]:="extra arg "; - %----------------------------------------------------------------------------------------------- + %--------------------------------------------------------------------------------------------- + if mc_row>=1: + %--------------------------------------------------------------------------------------------- for i=1 upto length(s): temp_c:=subc(i,s); if temp_c<>" ": char_cnt:=char_cnt+1; mc_char[char_cnt]:=ASCII(temp_c); fi endfor mc_char[0]:=mc_char[char_cnt+1]:=mc_char[char_cnt+2]:=a_cmm; - %-- argument missing chkeck -------------------------------------------------------------------- - a_prn_s_cnt:=a_prn_e_cnt:=a_brc_s_cnt:=a_brc_e_cnt:=a_brk_s_cnt:=a_brk_e_cnt:=0; - nA:=f_depth:=cmm_cnt:=0; + %-- argument missing chkeck ---------------------------------------------------------------- + cnt_prn_s:=cnt_prn_e:=cnt_brc_s:=cnt_brc_e:=cnt_brk_s:=cnt_brk_e:=cnt_inline_def:=cnt_at:=0; + cnt_cmm:=cnt_and:=cnt_gtn:=cnt_gtn:=0; + nA:=f_depth:=0; forever: nA:=nA+1; nB:=mc_char[nA-1]; nC:=mc_char[nA]; nD:=mc_char[nA+1]; - %--------------------------------------------------------------------------------------------- - if nC=a_cmm: if f_depth=0: cmm_cnt:=cmm_cnt+1; cmm_adr[cmm_cnt]:=nA; fi + %----------------------------------------------------------------------------------------- + if nC=a_cmm: if f_depth=0: cnt_cmm:=cnt_cmm+1; cmm_adr[cnt_cmm]:=nA; fi ef nC=a_ast: if nD=a_sls: - if mc_char[nA+2]=a_ast: if mc_char[nA+3]=a_cmm: proc_error(7,nA) nA:=nA+2; fi % */* x - ef mc_char[nA+2]=a_cmm: proc_error(7,nA) nA:=nA+1; fi % */ x - ef nD=a_ast: if mc_char[nA+2]=a_cmm: proc_error(7,nA) nA:=nA+1; fi fi % ** x - ef nC=a_sls: if nD=a_sls: if mc_char[nA+2]=a_cmm: proc_error(7,nA) nA:=nA+1; fi % // x - ef nD=a_ast: if mc_char[nA+2]=a_cmm: proc_error(7,nA) nA:=nA+1; fi % /* x - ef nD=a_cmm: proc_error(7,nA) fi % / x - ef nC=a_hsh: if nD=a_hsh: nA:=nA+1; % ## - ef nD=a_cmm: proc_error(7,nA) fi % # x - if nB<>a_cmm: proc_error(8,nA) fi % a # - ef nC=a_dol: if nD=a_cmm: proc_error(7,nA) fi % $ x - ef nC=a_equ: if nD= a_cmm: proc_error(7,nA) fi % = x - if nB= a_cmm: proc_error(7,nA) fi % x = - ef nC=a_cln: if nD= a_cmm: proc_error(7,nA) fi % : x - if nB= a_cmm: proc_error(7,nA) fi % x : - ef nC=a_amk: if nD= a_cmm: proc_error(7,nA) fi % @ x - if nB<>a_cmm: proc_error(8,nA) fi % a @ - ef nC=a_and: if nD= a_cmm: proc_error(7,nA) fi % & x - if nB<>a_cmm: proc_error(8,nA) fi % a & - ef nC=a_gtn: if nD= a_cmm: proc_error(7,nA) fi % < x - if nB<>a_cmm: proc_error(8,nA) fi % a < - ef nC=a_ltn: if nD= a_cmm: proc_error(7,nA) fi % > x - if nB= a_cmm: proc_error(7,nA) fi % x > - ef nC=a_tld: if nD= a_cmm: proc_error(7,nA) fi % ~ x - if nB= a_cmm: proc_error(7,nA) fi % x ~ - ef nC=a_hat: if nD= a_cmm: proc_error(7,nA) fi % ^ x - if nB= a_cmm: proc_error(7,nA) fi % x ^ - ef nC=a_bqt: if nD= a_cmm: proc_error(7,nA) fi % ` x - if nB= a_cmm: proc_error(7,nA) fi % x ` - %--------------------------------------------------------------------------------- - ef nC=a_prn_s: a_prn_s_cnt:=a_prn_s_cnt+1; f_depth:=1; - ef nC=a_prn_e: a_prn_e_cnt:=a_prn_e_cnt+1; f_depth:=0; - ef nC=a_brc_s: a_brc_s_cnt:=a_brc_s_cnt+1; f_depth:=1; - ef nC=a_brc_e: a_brc_e_cnt:=a_brc_e_cnt+1; f_depth:=0; - ef nC=a_brk_s: a_brk_s_cnt:=a_brk_s_cnt+1; f_depth:=1; - ef nC=a_brk_e: a_brk_e_cnt:=a_brk_e_cnt+1; f_depth:=0; - %--------------------------------------------------------------------------------- + if mc_char[nA+2]=a_ast: if mc_char[nA+3]=a_cmm: proc_err(7,nA) nA:=nA+2; fi % */* x + ef mc_char[nA+2]=a_cmm: proc_err(7,nA) nA:=nA+1; fi % */ x + ef nD=a_ast: if mc_char[nA+2]=a_cmm: proc_err(7,nA) nA:=nA+1; fi fi % ** x + ef nC=a_sls: if nD=a_sls: if mc_char[nA+2]=a_cmm: proc_err(7,nA) nA:=nA+1; fi % // x + ef nD=a_ast: if mc_char[nA+2]=a_cmm: proc_err(7,nA) nA:=nA+1; fi % /* x + ef nD=a_cmm: proc_err(7,nA) fi % / x + ef nC=a_hsh: if nD=a_hsh: nA:=nA+1; % ## + ef nD=a_cmm: proc_err(7,nA) fi % # x + if nB<>a_cmm: proc_err(8,nA) fi % a # + ef nC=a_dol: if nD=a_cmm: proc_err(7,nA) fi % $ x + ef nC=a_equ: if nD= a_cmm: proc_err(7,nA) fi % = x + if nB= a_cmm: proc_err(7,nA) fi % x = + ef nC=a_cln: if nD= a_cmm: proc_err(7,nA) fi % : x + if nB= a_cmm: proc_err(7,nA) fi % x : + ef nC=a_amk: cnt_at:=cnt_at+1; + if nD= a_cmm: proc_err(7,nA) fi % @ x + if nB<>a_cmm: proc_err(8,nA) fi % a @ + ef nC=a_and: cnt_and:=cnt_and+1; + if nD= a_cmm: proc_err(7,nA) fi % & x + if nB<>a_cmm: proc_err(8,nA) fi % a & + ef nC=a_gtn: cnt_gtn:=cnt_gtn+1; + if nD= a_cmm: proc_err(7,nA) fi % < x + if nB<>a_cmm: proc_err(8,nA) fi % a < + ef nC=a_ltn: if nD= a_cmm: proc_err(7,nA) fi % > x + if nB= a_cmm: proc_err(7,nA) fi % x > + ef nC=a_tld: if nD= a_cmm: proc_err(7,nA) fi % ~ x + if nB= a_cmm: proc_err(7,nA) fi % x ~ + ef nC=a_hat: if nD= a_cmm: proc_err(7,nA) fi % ^ x + if nB= a_cmm: proc_err(7,nA) fi % x ^ + ef nC=a_bqt: if nD= a_cmm: proc_err(7,nA) fi % ` x + if nB= a_cmm: proc_err(7,nA) fi % x ` + ef nC=a_bar: if nD= a_bar: + if mc_char[nA+2]=a_bar: nA:=nA+1; % || + ef mc_char[nA+2]<>a_cmm: proc_err(8,nA) % | a + fi + if nB<>a_cmm: proc_err(8,nA) fi % a | + fi + %------------------------------------------------------------------------------------------ + ef nC=a_prn_s: cnt_prn_s:=cnt_prn_s+1; f_depth:=1; + if nB=a_qut: cnt_inline_def:=cnt_inline_def+1; fi + ef nC=a_prn_e: cnt_prn_e:=cnt_prn_e+1; f_depth:=0; + ef nC=a_brc_s: cnt_brc_s:=cnt_brc_s+1; f_depth:=1; + ef nC=a_brc_e: cnt_brc_e:=cnt_brc_e+1; f_depth:=0; + if nD=a_cln: cnt_chg_atoms:=cnt_chg_atoms+1; + ef nD=a_equ: cnt_chg_bonds:=cnt_chg_bonds+1; + fi + ef nC=a_brk_s: cnt_brk_s:=cnt_brk_s+1; f_depth:=1; + ef nC=a_brk_e: cnt_brk_e:=cnt_brk_e+1; f_depth:=0; + %------------------------------------------------------------------------------------------- fi exitif nA>=char_cnt+1; endfor - %-- brackets balance check --------------------------------------------------------------------- - if a_prn_s_cnt>a_prn_e_cnt: proc_error(1,0) ef a_prn_s_cnt<a_prn_e_cnt: proc_error(2,0) fi - if a_brc_s_cnt>a_brc_e_cnt: proc_error(3,0) ef a_brc_s_cnt<a_brc_e_cnt: proc_error(4,0) fi - if a_brk_s_cnt>a_brk_e_cnt: proc_error(5,0) ef a_brk_s_cnt<a_brk_e_cnt: proc_error(6,0) fi - %----------------------------------------------------------------------------------------------- + %-- brackets balance check ------------------------------------------------------------------- + if cnt_prn_s>cnt_prn_e: proc_err(1,0) ef cnt_prn_s<cnt_prn_e: proc_err(2,0) fi + if cnt_brc_s>cnt_brc_e: proc_err(3,0) ef cnt_brc_s<cnt_brc_e: proc_err(4,0) fi + if cnt_brk_s>cnt_brk_e: proc_err(5,0) ef cnt_brk_s<cnt_brk_e: proc_err(6,0) fi + %--------------------------------------------------------------------------------------------- + else: + proc_err(0,0) + fi + %--------------------------------------------------------------------------------------------- for i=1 upto err_cnt: message "*"&fdr(3)(i)&" "&err_type[err_code[i]]&fdr(4)(err_adr[i])&" '"&err_str[i]&"'"; endfor -%%%%%% readstring; +%%%%%%% if (f_MP=1)and(err_cnt>0): readstring; fi err_cnt enddef; %------------------------------------------------------------------------------------------------- -def proc_error(expr ERR_CODE,ADR)= - err_cnt:=err_cnt+1; err_adr[err_cnt]:=ADR; - err_code[err_cnt]:=ERR_CODE; +def proc_err(expr ERR_CODE,ADR)= + err_cnt:=err_cnt+1; err_adr[err_cnt]:=ADR; err_code[err_cnt]:=ERR_CODE; if ERR_CODE<=6: err_str[err_cnt]:=" "; - else: err_str[err_cnt]:=substring (ADR-3,ADR+2) of mc; + else: err_str[err_cnt]:=substring (ADR-3,ADR+2) of mc; fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |