diff options
author | Karl Berry <karl@freefriends.org> | 2021-03-01 22:57:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-03-01 22:57:01 +0000 |
commit | c52df536e629025874412e05ab8d076c39ff9a62 (patch) | |
tree | 5181d9928dc30417158cb72709389006c5c31953 /Master/texmf-dist/metapost | |
parent | c8927b35230f875cf5936f91e4c35c4f5844f043 (diff) |
mcf2graph (1mar21) (branch)
git-svn-id: svn://tug.org/texlive/branches/branch2020.0@58033 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 172 |
1 files changed, 122 insertions, 50 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 4a3f4a766ab..9c68e1d84c9 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.58 Copyright (c) 2013-2021 Akira Yamaji +% mcf2graph ver 4.59 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,34 +37,37 @@ % Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; -message "* This is mcf2graph ver 4.58 2021.02.21"; +message "* This is mcf2graph ver 4.59 2021.02.28"; %------------------------------------------------------------------------------------------------- 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; numeric save_num[],comD[][],parD[][],adrD[][],cntD[],tbl_atom[],tbl_group[][],f_char[], tbl_atom_wt[],tbl_atom_mi[],tbl_char_wd[],tbl_char_ht[],addA[],add_rot[],chargeA[], com_group[][],par_group[][],cnt_group[],colorA[],colorB[],sumA[],bondC[],hideH[], - lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],numS[],wdM[],htM[],wdA[],dxA[]; -string info[],mc[],save_str[],tbl_atom_str[],strD[],tag[],out_file_name,out_file_aux, + lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],numS[],wdM[],htM[],wdA[],dxA[],mc_indent[]; +string save_str[],tbl_atom_str[],strD[],tag[],out_file_name,out_file_aux, out_file_rep,out_file_mpc,aux_delimiter,atomfont,mpfont,s_tag,s_var,cal_FM,cal_MW,cal_MI, - inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW,mc,blank_str; -pair save_pair[],posA[],posM[][],msize,mposition,fsize,fmargin,save_mposition,posBs,posBe; + inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW,blank_str; +pair save_pair[],posA[],posM[][],msize,mposition,fsize,fmargin,save_mposition,posBs,posBe,dum; picture mol_stru[],atom_picture,save_picture,temp_picture; path arrow_path,dottedline_path,line_path,arrow_head; %------------------------------------------------------------------------------------------------- char_num:=str_cnt:=tbl_cnt:=proc_end:=mangle:=sw_calc:=sw_ext_all:=0; sw_numberA:=sw_numberB:=sw_aux_out:=sw_expand:=sw_fframe:=sw_mframe:=sw_aframe:=sw_trimming:=0; -sw_rep_out:=sw_mol_out:=sw_group_off:=sw_single:=sw_arrow_emu:=sw_indent_off:=0; +sw_rep_out:=sw_mol_out:=sw_group_off:=sw_single:=sw_arrow_emu:=0; numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095; %------------------------------------------------------------------------------------------------- aux_max:=max_inf_num:=20; aux_delimiter:=";"; for i=1 upto aux_max: tag[i]:=""; endfor blank_str:= " "; +dum:=(-4091,0); %------------------------------------------------------------------------------------------------- -a_paren_s:=ASCII("("); a_paren_e:=ASCII(")"); a_brace_s:=ASCII("{"); a_brace_e:=ASCII("}"); -a_bracket_s:=ASCII("["); a_bracket_e:=ASCII("]"); a_comma:=ASCII(","); a_equal:=ASCII("="); -a_colon:=ASCII(":"); a_atmark:=ASCII("@"); a_zero:=ASCII("0"); a_nine:=ASCII("9"); +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"); %-------------------------------------------------------------------------------------------------- let DIV= /; let MUL= *; let LT= <; let GT= >; let AND= &; let :: = : ; let == = =; let ef=elseif; def ]]]=] ] ] enddef; @@ -211,12 +214,12 @@ def_com(-4090)(_com,_jp_atom,_jp_absA,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_t _chg_len,_get_len,_ring_len,_tmp_len,_rot_ang,_adj_ang,_chg_env,_tmp_env,_set_colorA,_set_colorB, _group_si,_set_adr,_mk_bond,_set_atom,_arrange_ang,_chg_atom,_tmp_rot,_fuse,_size_atom,_numeric, _jump_at,_set_add,_chg_add,_nop,_mark,_moff,_term,_len_s,_len_e,_len_ss,_len_ee, - _group_s,_group_e,_rest,_charge, + _group_s,_group_e,_rest,_charge,_zero_ang, si,dl,dl_,dr,dr_,db,dm,dm_,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,nb,si_,wf_,wb_,zf_,zb_,wv_,bd_); %-------------------------------------------------------------------------------------------------- def parameter_list= sw_rep_out,sw_numberA,sw_numberB,sw_mframe,sw_aux_out,sw_expand,sw_mol_out,sw_calc, - sw_single,sw_ext_all,sw_aframe,sw_fframe,sw_group_off,sw_trimming,sw_arrow_emu,sw_indent_off, + sw_single,sw_ext_all,sw_aframe,sw_fframe,sw_group_off,sw_trimming,sw_arrow_emu, ratio_atom_bond,ratio_thickness_bond,ratio_char_bond,ratio_chain_ring,ratio_bondgap_bond, ratio_zebra_black,ratio_zebragap_bond,ratio_thickness_char,ratio_wedge_bond,ratio_atomgap_atom, lonepairdiam,lonepairspace,blength,offset_atom,offset_wedge,max_blength,offset_zebra_gap, @@ -258,7 +261,8 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def beginfont(text s)= begingroup - save ',f_beginchar,f_ext,blen,ext,add,ang_br,s_fw,s_bw,s_len,at_colon; + save ',f_beginchar,f_ext,blen,ext,add,ang_br,s_fw,s_bw,s_len,at_colon,info,mc; + string info[],mc[],mc; %------------------------------------------------------------------------------------------------ def ext=ext_to_font enddef; def add=add_to_molecule enddef; @@ -272,9 +276,8 @@ def beginfont(text s)= %------------------------------------------------------------------------------------------------ char_num:=char_num+1; store_par(parameter_list); - for i:=1 upto max_inf_num: info[i]:=":"; mc[i]:=""; endfor - f_ext:=inf_num:=cntM:=mc_low:=0; - for list=s: inf_num:=inf_num+1; info[inf_num]:=list; endfor + f_ext:=cntM:=mc_low:=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: at_colon:=0; @@ -284,13 +287,9 @@ def beginfont(text s)= 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; - if sw_indent_off=0: - mc[mc_low]:=substring (2,s_len) of info[j]; - mc:=mc&substring (s_fw-1,s_bw) of info[j]; - else: - mc[mc_low]:=substring (s_fw-1,s_len) of info[j]; - mc:=mc&mc[mc_low]; - fi + mc_indent[mc_low]:=s_fw-2; + mc[mc_low]:=substring (s_fw-1,s_bw) of info[j]; + mc:=mc&mc[mc_low]; ef at_colon>=1: s_tag:=substring (0,at_colon-1) of info[j]; s_var:=substring (at_colon,s_len) of info[j]; @@ -339,7 +338,7 @@ def endfont= if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0) else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht; fi - draw (0,h)--(0,0)--(w,0)--(w,h)--(0,h)--(w,0) wpcs 0.2bp; + draw (0,h)--(0,0)--(w,0)--(w,h)--(0,h)--(w,0) wpcs thickness_fframe; fi %----------------------------------------------------------------------------------------- endchar; @@ -354,7 +353,7 @@ 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); @@ -369,21 +368,25 @@ enddef; %------------------------------------------------------------------------------------------------- vardef '(text TXT)= parts_cnt:=parts_cnt+1; read_mcf(parts_cnt)(TXT); parts_cnt enddef; vardef read_id(text TXT)=read_mcf(incr parts_cnt)(|,#crR,TXT,##,(_com,_rest)); parts_cnt enddef; -vardef read_ud(text TXT)=read_mcf(incr parts_cnt)(|,TXT,(_com,_rest)); parts_cnt enddef; +vardef read_ud(text TXT)=read_mcf(incr parts_cnt)(dum,dum,|,TXT,(_com,_rest)); parts_cnt enddef; +vardef abs_adress primary n == n-4095 enddef; tertiarydef a op_equ b = if (known a)and(known b):: change_bond(a,b) else:: _nop fi enddef; tertiarydef a op_col b = if (known a)and(known b):: change_atom(a,b) else:: _nop fi enddef; tertiarydef a op_hat b = if known b:: (_tmp_rot,b),a else:: _nop,a fi enddef; tertiarydef a op_til b = if known b:: (_tmp_line,b),a else:: _nop,a fi enddef; tertiarydef a op_lt b = if known b:: (_tmp_env,b),a else:: _nop,a fi enddef; tertiarydef a op_bq b = if known b:: (_tmp_len,b),a else:: _nop,a fi enddef; -def rot_angle primary n = (_rot_ang,n) enddef; def jump_atom primary n = (_jp_atom,n) enddef; +def rot_angle primary n = (_rot_ang,n) enddef; def cyc_atom primary n = (_cyc,n) enddef; -def chg_length primary n = (_com,_len_s),(_chg_len,n) enddef; +def jump_atom primary a = + if numeric a:: (_jp_atom,a) + elseif pair a:: (_jp_atom,$1),(_com,_zero_ang),angle(a)~0`length(a),(_com,_zero_ang) fi +enddef; +def chg_length primary n = (_com,_len_s),(_chg_len,n) enddef; def group_si secondary n == if known n:: (_group_si,n) else:: _nop fi enddef; def group_dm secondary n == /n~dm enddef; def group_wf secondary n == /n~wf enddef; def group_zf secondary n == /n~zf enddef; def group_wv secondary n == /n~wv enddef; def group_nb secondary n == /n~nb enddef; -vardef abs_adress primary n == n-4095 enddef; %------------------------------------------------------------------------------------------------- def CP = com_par enddef; def CPe = com_par_ex(0) enddef; def CPx = com_par_ex(1) enddef; %================================================================================================= @@ -1048,6 +1051,7 @@ def proc_skeleton(expr a)= ef com=_com: if par=_mark: saveA:=markA; saveB:=markB; markA:=cntA; markB:=cntB; ef par=_rest: markA:=saveA; markB:=saveB; ef par=_moff: markA:=markB:=0; ef par=_term: termB; + ef par=_zero_ang: angT:=0; ef par=_group_e: lineT:=si; lenT:=crR; rotT:=envT:=0; fi ef com=_jp_bond: termB; nA:=getB(par); posBs:=posA[sB[nA]]; angT:=angB[nA]; f_bra:=1; rotT:=0; ef com=_jp_atom: termB; adrT:=getA(par); posBs:=posA[adrT]; angT:=angX[adrT]; f_bra:=1; rotT:=0; @@ -1091,7 +1095,7 @@ enddef; vardef arrange_ang(expr n)= if cntB=0: angT:=(angT-180) mod 360; 180 else: - if envB>=parts_emb_start: parD[envB][cntB-temp_cntB+2] + if envB>=parts_emb_start: parD[envB][cntB-temp_cntB+3] else: if envB=hz: if n=0: 60 ef n<=90: -60 ef n<=180: 60 ef n<270: -60 else: 60 fi ef envB=vt: if n=0: -60 ef n<90: 60 ef n<=180: -60 ef n<=270: 60 else: -60 fi ef abs(envB)<=180: envB fi @@ -1570,15 +1574,24 @@ enddef; def proc_report_out= message "["&decimal(char_num)&"]:"&inf_EN; out_file_name:=out_file_rep; - printf "------------------------------------------------------------------"; - printf " Molecular name = "& inf_EN; + printf "==========================================================================="; + printf " No."&fdr(4)(char_num)&" / Name = "& inf_EN; + if mc_low>=1: + printf "---------------------------------------------------------------------------"; + for i=1 upto mc_low: + 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); + fi + printf "---------------------------------------------------------------------------"; printf " Warnings = "&fdr(3)(warning_cnt)&" / Command count= "&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); printf " Atom count="&fdr(3)(cntA)&" Bond count="&fdr(3)(cntB)& " Ring count="&fdr(3)(cntB-cntA+1)&" Hide H count="&fdr(3)(hideH_cnt); - printf "------------------------------------------------------------------"; + printf "---------------------------------------------------------------------------"; printf "< NO. ><atom(s) >( x axis , y axis )<bond><hideH><chg>"; for i=1 upto cntA: printf " A"&fdl(6)(i)&fsl(8)(erase_brace(strD[numS[i]]))& @@ -1587,18 +1600,16 @@ def proc_report_out= iif(hideH[i]>0,fdr(6)(hideH[i])," ") if chargeA[i]<>0: &fdr(4)(chargeA[i]) fi; endfor - printf "------------------------------------------------------------------"; + printf "---------------------------------------------------------------------------"; printf "< NO. >< bond (sdt)><angle +( +- )><length ( pt )>"; for i=1 upto cntB: nC:=lenB[i]; if nC=_size_atom: nC:=ratio_atom_bond; elseif nC<0: nC:=-nC; fi - if lineB[i]<>0: nB:=angB[i]; if nB>180: nB:=nB-360; fi printf " B"&fdl(4)(i)&fdr(3)(sB[i])&" -> "&fdr(3)(eB[i])& " ("&fdr(3)(bondC[i])&")"&fdr(8)(round_auto(angB[i]))& " ("&fdr(6)(round_auto(nB))&")"&fdr(8)(nC)&" ("&fdr(8)(round_auto(nC*blen))&")"; - fi endfor - printf "------------------------------------------------------------------"; + printf "---------------------------------------------------------------------------"; printf "<atom>( atom wt )[ mi wt ] < cnt > < sum wt >[ sum mi wt ]"; for i=1 upto tbl_atom_max: if sumA[i]>=1: @@ -1612,12 +1623,12 @@ def proc_report_out= fi endfor printf " Molecular Weight [Mono Isotopic] = "&fsr(12)(cal_MW)&"["&fsr(12)(cal_MI)&"]"; - printf "------------------------------------------------------------------"; + printf "---------------------------------------------------------------------------"; printf " Weight Calc: " &cal_MW &" / Input: " if inf_MW<>"-": &inf_MW &" / weight gap= " &decimal(num_MW-scantokens(inf_MW)) fi; printf " Fomula Calc: "&cal_FM&" / Input: " if inf_FM<>"-": &inf_FM&" / "& iif(inf_FM=cal_FM,"MACTCH","NOT MACTCH") fi; - printf "=================================================================="; + printf "==========================================================================="; enddef; %================================================================================================= def proc_mol_out= @@ -1761,7 +1772,8 @@ NH!?!:='(NH,!,?!); NHCO!:='(NH,!,//O,!); CONH2:='(//O,!,NH2); ??:='(/_^35,/_^-35 CF2:='(/F,60,F); CCl2:='(/Cl,60,Cl); CBr2:='(/Br,60,Br); CF3:='(/F,/F^60,60,F); CCl3:='(/Cl,/Cl^60,60,Cl); CBr3:='(/Br,/Br^60,60,Br); %------------------------------------------------------------------------------------------------- -lr:='(60 for i==1 upto 10:: ,-60,60 endfor); rl:='(-60,lr); +lr:='(0,0,0,60 for i==1 upto 10:: ,-60,60 endfor); +rl:='(0,0,0,-60 for i==1 upto 10:: ,60,-60 endfor); for i=4,5,6: for j=2 upto i-2: ?[i][j]:='((_fuse,i),(j,0)); endfor endfor for i=5,6,7,8: for j=11 upto 15: ?[i][j]:='((_fuse,i),(j,0)); endfor endfor %------------------------------------------------------------------------------------------------- @@ -1784,26 +1796,86 @@ def expand_set= !SH:='(!,SH); !NO2:='(!,NO2); enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -vardef check_mc(expr s)= %%%%% prototype version %%%%%% +vardef check_mc(expr s)= save mc_char,mc_char,temp_c,err_cnt,char_cnt; - string temp_c; - numeric mc_char[]; - err_cnt:=char_cnt:=nA:=nB:=nC:=nD:=nE:=nF:=0; + string temp_c,err_str[],err_type[]; + numeric mc_char[],err_adr[],err_code[]; + err_cnt:=char_cnt:=code_cnt:=0; + 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 "; %----------------------------------------------------------------------------------------------- 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 -------------------------------------------------------------------- + nA:=1; + forever: + nB:=mc_char[nA-1]; nC:=mc_char[nA]; nD:=mc_char[nA+1]; nE:=mc_char[nA+2]; nF:=mc_char[nA+3]; + %--------------------------------------------------------------------------------------------- + if nC=a_cmm: + ef (nC=a_ast)and(nD=a_sls)and(nE=a_ast)and(nF=a_cmm): proc_error(7,nA) nA:=nA+3; % */* x + ef (nC=a_sls)and(nD=a_sls)and(nE=a_cmm): proc_error(7,nA) nA:=nA+2; % // x + ef (nC=a_sls)and(nD=a_ast)and(nE=a_cmm): proc_error(7,nA) nA:=nA+2; % /* x + ef (nC=a_ast)and(nD=a_sls)and(nE=a_cmm): proc_error(7,nA) nA:=nA+2; % */ x + ef (nC=a_ast)and(nD=a_ast)and(nE=a_cmm): proc_error(7,nA) nA:=nA+2; % ** x + ef (nC=a_hsh)and(nD=a_hsh): nA:=nA+2; % ## + ef (nC=a_sls)and(nD=a_cmm): proc_error(7,nA) % / x + ef (nC=a_dol)and(nD=a_cmm): proc_error(7,nA) % $ 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_hsh: 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 ` + %--------------------------------------------------------------------------------- + fi + nA:=nA+1; + exitif nA>=char_cnt; + endfor %-- check brackets ----------------------------------------------------------------------------- + nA:=nB:=nC:=nD:=nE:=nF:=0; for i=1 upto char_cnt: - if mc_char[i]=a_paren_s: nA:=nA+1; ef mc_char[i]=a_paren_e: nB:=nB+1; - ef mc_char[i]=a_brace_s: nC:=nC+1; ef mc_char[i]=a_brace_e: nD:=nD+1; - ef mc_char[i]=a_bracket_s: nE:=nE+1; ef mc_char[i]=a_bracket_e: nF:=nF+1; + if mc_char[i]=a_prn_s: nA:=nA+1; ef mc_char[i]=a_prn_e: nB:=nB+1; + ef mc_char[i]=a_brc_s: nC:=nC+1; ef mc_char[i]=a_brc_e: nD:=nD+1; + ef mc_char[i]=a_brk_s: nE:=nE+1; ef mc_char[i]=a_brk_e: nF:=nF+1; fi endfor - if nA<>nB: err_cnt:=err_cnt+1; fi if nC<>nD: err_cnt:=err_cnt+1; fi - if nE<>nF: err_cnt:=err_cnt+1; fi + if nA>nB: proc_error(1,0) ef nA<nB: proc_error(2,0) fi + if nC>nD: proc_error(3,0) ef nC<nD: proc_error(4,0) fi + if nE>nF: proc_error(5,0) ef nE<nF: proc_error(6,0) fi %----------------------------------------------------------------------------------------------- - if err_cnt>=1: message "* "&decimal(err_cnt)&"fatal error"; 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; 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; + if ADR=0: err_str[err_cnt]:=" "; else: err_str[err_cnt]:=substring (ADR-3,ADR+2) of mc; fi +enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |