#!/bin/perlundef $/ ;$_ = <> ;################################################################                                                             ##   New macro to set the defaults of GasTeX 1                 ##   Default unitlength. In GasTeX 1: 4pt, in GasTeX 2: 1mm    ##                                                             ################################################################s!\\usepackage{pspictpg,gastex}!\\usepackage{gastex}!gx;s!\\begin{document} !\\makeatletter\\def\\defaultSettingsForGastexUn{\t\\d\@my\@unit=2048sp\t\\gasset{Nw=6,Nh=6,Nmr=3}\t\\gasset{Nframe=y,fillgray=0,Nfill=n}\t\\gasset{ExtNL=n,NLangle=90,NLdist=0}\t\\gasset{iangle=180,ilength=3,fangle=0,flength=3,rdist=0.5,Nmarks=n}\t\\gasset{Nadjustdist=1,Nadjust=n}\t\\gasset{loopdiam=6,loopangle=90,curvedepth=3}\t\\gasset{AHnb=1,AHdist=1,AHangle=20,AHLength=1.1,AHlength=1.03} \t\\gasset{ELside=l,ELpos=50,ELdist=1}\t\\gasset{linegray=0,linewidth=0.1,dash={}0}\t\\def\\transdecal{0}}\\def\\psdashForGastexUn[\#1](\#2){\t\\def\\gas\@dash{[\#2] \#1\\space setdash\\space}}\\def\\drawnodeWhichShouldBeAvoided{\\draw\@node}\\makeatother\\begin{document}!gx;s!([\ \t]*?)\\begin{picture}(.*?)\n !$1\\unitlength=4pt\n$1\\begin{picture}$2\n$1\\defaultSettingsForGastexUn\n!gx;################################################                                             ##   New syntax for the settings of GasTeX 1   #### Manque \setrepeatedstatediam ###############                                             ################################################s!\\setvertexdiam!\\setstatediam!gx;# \setstatediam{5}s!\\setstatediam{(.*?)} !\\gasset{Nw=$1,Nh=$1,Nmr=$1}!gx; # \setloopdiam{10}s!\\setloopdiam{(.*?)} !\\gasset{loopdiam=$1}!gx;# \settranslabelskip{5}s!\\setedgelabelskip!\\settranslabelskip!gx;s!\\settranslabelskip{(.*?)} !\\gasset{ELdist=$1}!gx; # \setprofcurve{5}s!\\setprofcurve{(.*?)} !\\gasset{curvedepth=$1}!gx;s!\\setedgedecal!\\def\\transdecal!gx;s!\\settransdecal!\\def\\transdecal!gx;s!\\setmaxbezier{(.*?)}!!gx;s!\\setnbptbezier{(.*?)}!!gx;s!\\setprecision{(.*?)}!!gx;# add the default option if no option is givens!\\setpsdash\(!\\setpsdash\[0\]\(!gx;s!\\setpsdash!\\psdashForGastexUn!gx;###############            ##   States   ##            ################ add the default option if no option is givens!\\drawinitialstate\(!\\drawinitialstate\[l\]\(!gx;s!\\drawfinalstate\(!\\drawfinalstate\[r\]\(!gx;# reorder the macros \drawXXXstate: initial then final and last repeateds!(\\drawfinalstate\[.\]\((.*?)\){.*?}) (\s*?) (\\drawinitialstate\[.\]\(\2\){.*?}) !$4$3$1!gx;s!(\\drawrepeatedstate\((.*?)\){.*?}) (\s*?) (\\drawinitialstate\[.\]\(\2\){.*?}) !$4$3$1!gx;s!(\\drawrepeatedstate\((.*?)\){.*?}) (\s*?) (\\drawfinalstate\[.\]\(\2\){.*?}) !$4$3$1!gx;s!(\\drawfinalstate\[.\]\((.*?)\){.*?}) (\s*?) (\\drawinitialstate\[.\]\(\2\){.*?}) !$4$3$1!gx;################################                             ##   States with three marks   ##                             #################################  \letstate[10,8] A1=(0,0)#  \drawinitialstate[r](A1){}#  \drawfinalstate[r](A1){$2$}#  \drawrepeatedstate(A1){$1$}s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\)  \s*? \\drawinitialstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawfinalstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawrepeatedstate\(\1\){(.*?)} !\\node[Nmarks=ifr,iangle=$5,fangle=$7,Nw=$1,Nh=$1,Nmr=$1,rdist=t\@d\@$1-$2t\@d\@]($3)($4){$6$8$9}!gx;#  \letstate A1=(0,0)#  \drawinitialstate[r](A1){}#  \drawfinalstate[r](A1){$2$}#  \drawrepeatedstate(A1){$1$}s!\\letstate \s*? (.*?)=\((.*?)\)  \s*? \\drawinitialstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawfinalstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawrepeatedstate\(\1\){(.*?)} !\\node[Nmarks=ifr,iangle=$3,fangle=$5]($1)($2){$4$6$7}!gx;##############################                           ##   States with two marks   ##                           ###############################  \letstate[10,8] A1=(0,0) \drawinitialstate[r](A1){} \drawfinalstate[r](A1){$2$}s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\)  \s*? \\drawinitialstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawfinalstate\[(.)\]\(\1\){(.*?)} !\\node[Nmarks=if,iangle=$5,fangle=$7,Nw=$1,Nh=$1,Nmr=$1]($3)($4){$6$8}!gx;#  \letstate A1=(0,0) \drawinitialstate[r](A1){} \drawfinalstate[r](A1){$2$}s!\\letstate \s*? (.*?)=\((.*?)\)  \s*? \\drawinitialstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawfinalstate\[(.)\]\(\1\){(.*?)} !\\node[Nmarks=if,iangle=$3,fangle=$5]($1)($2){$4$6}!gx;#  \letstate[10,8] A1=(0,0) \drawinitialstate[r](A1){} \drawrepeatedstate(A1){$1$}s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\)  \s*? \\drawinitialstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawrepeatedstate\(\1\){(.*?)} !\\node[Nmarks=ir,iangle=$5,Nw=$1,Nh=$1,Nmr=$1,rdist=t\@d\@$1-$2t\@d\@]($3)($4){$6$7}!gx;#  \letstate A1=(0,0) \drawinitialstate[r](A1){} \drawrepeatedstate(A1){$1$}s!\\letstate \s*? (.*?)=\((.*?)\)  \s*? \\drawinitialstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawrepeatedstate\(\1\){(.*?)} !\\node[Nmarks=ir,iangle=$3]($1)($2){$4$5}!gx;#  \letstate[10,8] A1=(0,0) \drawfinalstate[r](A1){} \drawrepeatedstate(A1){$1$}s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\)  \s*? \\drawfinalstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawrepeatedstate\(\1\){(.*?)} !\\node[Nmarks=fr,fangle=$5,Nw=$1,Nh=$1,Nmr=$1,rdist=t\@d\@$1-$2t\@d\@]($3)($4){$6$7}!gx;#  \letstate A1=(0,0) \drawfinalstate[r](A1){} \drawrepeatedstate(A1){$1$}s!\\letstate \s*? (.*?)=\((.*?)\)  \s*? \\drawfinalstate\[(.)\]\(\1\){(.*?)}  \s*? \\drawrepeatedstate\(\1\){(.*?)} !\\node[Nmarks=fr,fangle=$3]($1)($2){$4$5}!gx;##########################################################################                                                                       ##   States with no mark or only one mark (initial, final or repeated)   ##                                                                       ###########################################################################  \letstate[10,8] A1=(0,0) \drawstate(A1){$1$}s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\) \s*? \\drawstate\(\3\){(.*?)} !\\node[Nw=$1,Nh=$1,Nmr=$1]($3)($4){$5}!gx;#  \letstate A1=(0,0) \drawstate(A1){$1$}s!\\letstate \s*? (.*?)=\((.*?)\) \s*? \\drawstate\(\1\){(.*?)} !\\node($1)($2){$3}!gx;#  \letstate[10,8] A1=(0,0) \drawinitialstate[r](A1){$1$}s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\) \s*? \\drawinitialstate\[(.)\]\(\3\){(.*?)} !\\node[Nmarks=i,iangle=$5,Nw=$1,Nh=$1,Nmr=$1]($3)($4){$6}!gx;#  \letstate A1=(0,0) \drawinitialstate[r](A1){$1$}s!\\letstate \s*? (.*?)=\((.*?)\) \s*? \\drawinitialstate\[(.)\]\(\1\){(.*?)} !\\node[Nmarks=i,iangle=$3]($1)($2){$4}!gx;#  \letstate[10,8] A1=(0,0) \drawfinalstate[r](A1){$1$}s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\) \s*? \\drawfinalstate\[(.)\]\(\3\){(.*?)} !\\node[Nmarks=f,fangle=$5,Nw=$1,Nh=$1,Nmr=$1]($3)($4){$6}!gx;#  \letstate A1=(0,0) \drawfinalstate[r](A1){$1$}s!\\letstate \s*? (.*?)=\((.*?)\) \s*? \\drawfinalstate\[(.)\]\(\1\){(.*?)} !\\node[Nmarks=f,fangle=$3]($1)($2){$4}!gx;#  \letstate[10,8] A1=(0,0) \drawrepeatedstate(A1){$1$}s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\) \s*? \\drawrepeatedstate\(\3\){(.*?)} !\\node[Nmarks=r,Nw=$1,Nh=$1,Nmr=$1,rdist=t\@d\@$1-$2t\@d\@]($3)($4){$5}!gx;#  \letstate A1=(0,0) \drawrepeatedstate(A1){$1$}s!\\letstate \s*? (.*?)=\((.*?)\) \s*? \\drawrepeatedstate\(\1\){(.*?)} !\\node[Nmarks=r]($1)($2){$3}!gx;#################################################                                              ##   Vertices drawned with or without a circle  ##                                              ################################################# #  \letvertex[10] A1=(0,0) \drawvertex(A1){$1$}s!\\letvertex\[(.*?)\] \s* (.*?)=\((.*?)\) \s*? \\drawvertex\(\1\){(.*?)} !\\node[Nframe=n,Nfill=n,Nw=$1,Nh=$1,Nmr=$1]($2)($3){$4}!gx; #  \letvertex A1=(0,0) \drawvertex(A1){$1$}s!\\letvertex \s*? (.*?)=\((.*?)\) \s*? \\drawvertex\(\1\){(.*?)} !\\node[Nframe=n,Nfill=n]($1)($2){$3}!gx; #  \letvertex[10] A1=(0,0) \drawcircledvertex(A1){$1$}s!\\letvertex\[(.*?)\] \s* (.*?)=\((.*?)\) \s*? \\drawcircledvertex\(\1\){(.*?)} !\\node[Nw=$1,Nh=$1,Nmr=$1]($2)($3){$4}!gx; #  \letvertex A1=(0,0) \drawcircledvertex(A1){$1$}s!\\letvertex \s*? (.*?)=\((.*?)\) \s*? \\drawcircledvertex\(\1\){(.*?)} !\\node($1)($2){$3}!gx;############################################################                                                         ##   States or vertices that are defined but not drawned   ##                                                         #############################################################  \letstate[10,8] A1=(0,0)s!\\letstate\[(.*?),(.*?)\] \s* (.*?)=\((.*?)\) !\\node[Nframe=n,Nw=$1,Nh=$1,Nmr=$1]($3)($4){}!gx;#  \letstate A1=(0,0)s!\\letstate \s*? (.*?)=\((.*?)\) !\\node[Nframe=n]($1)($2){}!gx;#  \letvertex[10] A1=(0,0)s!\\letvertex\[(.*?)\] \s* (.*?)=\((.*?)\) !\\node[Nframe=n,Nw=$1,Nh=$1,Nmr=$1]($2)($3){}!gx;#  \letvertex A1=(0,0)s!\\letvertex \s*? (.*?)=\((.*?)\) !\\node[Nframe=n]($1)($2){}!gx;############################################################                                                         ##   If the following substitutions are used, there are    ##   states or vertices which are drawned but not just     ##   after being defined. Move the drawing of states       ##   or vertices after their definition to get a better    ##   translation from GasTeX 1 to GasTeX 2.                ##                                                         #############################################################  \drawstates!\\drawstate!\\drawnodeWhichShouldBeAvoided!gx;#  \drawvertex(A1){$1$}s!\\drawvertex\((.*?)\){(.*?)} !{\\gasset{Nframe=n}\\drawnodeWhichShouldBeAvoided($1){$2}}!gx;#  \drawcircledvertexs!\\drawcircledvertex!\\drawnodeWhichShouldBeAvoided!gx;#  \drawinitialstate[r](A1){$1$}s!\\drawinitialstate\[(.)\]\((.*?)\){(.*?)} !\\drawnodeWhichShouldBeAvoided($2){$3}\\imark[iangle=$1]($2)!gx;#  \drawfinalstate[r](A1){$1$}s!\\drawfinalstate\[(.)\]\((.*?)\){(.*?)} !\\drawnodeWhichShouldBeAvoided($2){$3}\\fmark[fangle=$1]($2)!gx;#  \drawrepeatedstate[r](A1){$1$}s!\\drawrepeatedstate\((.*?)\){(.*?)} !\\drawnodeWhichShouldBeAvoided($1){$2}\\rmark($1)!gx;####################                 ##   Transitions   ##                 ##################### \drawXXXedge is a synonyme of \drawXXXtrans in GasTeX 1s!\\drawedge!\drawtrans!gx;s!\\drawcurvededge!\drawcurvedtrans!gx;s!\\drawqbezieredge!\drawqbeziertrans!gx;s!\\drawcbezieredge!\drawcbeziertrans!gx;# add the default option if no option is givens!\\drawtrans\(!\\drawtrans\[l\]\(!gx;s!\\drawundirectededge\(!\\drawundirectededge\[l\]\(!gx;s!\\drawcurvedtrans\(!\\drawcurvedtrans\[l\]\(!gx;s!\\drawundirectedcurvededge\(!\\drawundirectedcurvededge\[l\]\(!gx;s!\\drawqbeziertrans\(!\\drawqbeziertrans\[l\]\(!gx;s!\\drawundirectedqbezieredge\(!\\drawundirectedqbezieredge\[l\]\(!gx;s!\\drawcbeziertrans\(!\\drawcbeziertrans\[l\]\(!gx;s!\\drawundirectedcbezieredge\(!\\drawundirectedcbezieredge\[l\]\(!gx;s!\\drawloop\(!\\drawloop\[t\]\(!gx;s!\\drawundirectedloop\(!\\drawundirectedloop\[t\]\(!gx;# use the new syntaxs!\\drawtrans\[(.)\] !\\drawedge[curvedepth=\\transdecal,ELside=$1]!gx;s!\\drawundirectededge\[(.)\] !\\drawedge[curvedepth=\\transdecal,AHnb=0,ELside=$1]!gx;s!\\drawcurvedtrans\[(.)\] !\\drawedge[ELside=$1]!gx;s!\\drawundirectedcurvededge\[(.)\] !\\drawedge[AHnb=0,ELside=$1]!gx;s!\\drawqbeziertrans\[(.)\]\((.*?)\)\((.*?),(.*?)\)\((.*?)\) !\\drawqbedge[ELside=$1]\($2,$3,$4,$5\)!gx;s!\\drawundirectedqbezieredge\[(.)\]\((.*?)\)\((.*?),(.*?)\)\((.*?)\) !\\drawqbedge[AHnb=0,ELside=$1]\($2,$3,$4,$5\)!gx;s!\\drawcbeziertrans\[(.)\]\((.*?)\)\((.*?),(.*?)\)\((.*?),(.*?)\)\((.*?)\) !\\drawbcedge[ELside=$1]\($2,$3,$4,$7,$5,$6\)!gx;s!\\drawundirectedcbezieredge\[(.)\]\((.*?)\)\((.*?),(.*?)\)\((.*?),(.*?)\)\((.*?)\) !\\drawbcedge[AHnb=0,ELside=$1]\($2,$3,$4,$7,$5,$6\)!gx;s!\\drawloop\[(.)\] !\\drawloop[loopangle=$1]!gx;s!\\drawundirectedloop\[(.)\] !\\drawloop[AHnb=0,loopangle=$1]!gx;########################################################################                                                                     ##   The above translations leave values for iangle, fangle ...        ##   that should be changed to comply with the syntax of GasTeX 2      ##                                                                     ######################################################################### iangle s!iangle=r!iangle=0!gx;s!iangle=t!iangle=90!gx;s!iangle=l!iangle=180!gx;s!iangle=b!iangle=270!gx;# fangles!fangle=r!fangle=0!gx;s!fangle=t!fangle=90!gx;s!fangle=l!fangle=180!gx;s!fangle=b!fangle=270!gx;# loopangle s!loopangle=r!loopangle=0!gx;s!loopangle=t!loopangle=90!gx;s!loopangle=l!loopangle=180!gx;s!loopangle=b!loopangle=270!gx;# compute the value that should be assigned to rdists!t\@d\@(.*?)-(.*?)t\@d\@!($1-$2)/2!egx;# old options from GasTeX 0.xs!ELside=t!ELside=l!gx;s!ELside=b!ELside=r!gx;print STDOUT $_ ;