summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/eolang/eolang.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/eolang/eolang.sty')
-rw-r--r--Master/texmf-dist/tex/latex/eolang/eolang.sty158
1 files changed, 110 insertions, 48 deletions
diff --git a/Master/texmf-dist/tex/latex/eolang/eolang.sty b/Master/texmf-dist/tex/latex/eolang/eolang.sty
index 3d3abf67d83..087801f400f 100644
--- a/Master/texmf-dist/tex/latex/eolang/eolang.sty
+++ b/Master/texmf-dist/tex/latex/eolang/eolang.sty
@@ -31,7 +31,13 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{eolang}
-[2022-10-30 0.3.0 Formulas and Graphs for EO Programming Language]
+[2022-11-05 0.4.0 Formulas and Graphs for EO Programming Language]
+
+
+
+
+
+
@@ -185,6 +191,16 @@ print '\endinput', "\n";
\makeatletter
\begin{VerbatimOut}{\eolang@tmpdir/eolang-sodg.pl}
+sub num {
+ my ($i) = @_;
+ $i =~ s/(\+|-)\./\10./g;
+ return $i;
+}
+sub fmt {
+ my ($tex) = @_;
+ $tex =~ s/\|([^\|]+)\|/\\textnormal{\\texttt{\1}}/g;
+ return $tex;
+}
open(my $fh, '<', $ARGV[0]);
my $tex; { local $/; $tex = <$fh>; }
print '% This file is auto-generated', "\n";
@@ -195,15 +211,15 @@ if (index($tex, "\t") > 0) {
print "TABS are prohibited!";
exit 1;
}
-$tex =~ s/^\s+|\s+$//g;
-$tex =~ s/(\\[a-zA-Z]+)\s+/\1/g;
-$tex =~ s/\n\s+/\n/g;
-$tex =~ s/\|([^\|]+)\|/\\textnormal{\\texttt{\1}}/g;
-my @cmds = split (/\n/g, $tex);
-foreach my $t (@cmds) {
+foreach my $t (split (/\n/g, $tex)) {
print '% ', $t, "\n";
}
print '% ---', "\n";
+$tex =~ s/^\s+|\s+$//g;
+$tex =~ s/\\\\/\n/g;
+$tex =~ s/(\\[a-zA-Z]+) +/\1/g;
+$tex =~ s/\n\s+/\n/g;
+my @cmds = split (/\n/g, $tex);
print '\begin{phicture}', "\n";
foreach my $c (@cmds) {
my ($head, $tail) = split (/ /, $c, 2);
@@ -212,23 +228,82 @@ foreach my $c (@cmds) {
my ($q, $t) = split (/:/, $p);
$opts{$q} = $t;
}
- if (index($head, '->') == -1) {
+ if (index($head, '->') >= 0) {
+ print '\draw[';
+ if (exists $opts{'pi'}) {
+ print ',phi-pi';
+ if (not exists $opts{'a'}) {
+ $opts{'a'} = '\pi';
+ }
+ }
+ print ']';
+ my ($from, $to) = split (/->/, $head);
+ print ' (', $from, ') ';
+ if (exists $opts{'bend'}) {
+ print 'edge [bend right=', num($opts{'bend'}), ']';
+ } else {
+ print '--';
+ }
+ if (exists $opts{'rho'} or exists $opts{'rrho'}) {
+ print ' pic[sloped,phi-rho]{parallel arrow={';
+ print '-' if not exists $opts{'rrho'};
+ print '0.3,-0.15}}';
+ }
+ if (exists $opts{'a'}) {
+ my $a = $opts{'a'};
+ if (index($a, '$') == -1) {
+ $a = '$' . fmt($a) . '$';
+ } else {
+ $a = fmt($a);
+ }
+ print ' node [phi-attr] {', $a, '}';
+ }
+ print ' (', $to, ')';
+ } elsif (index($head, '=>') >= 0) {
+ my ($from, $to) = split (/=>/, $head);
+ if ($from eq '') {
+ print '\node [phi-arrow, left=.6cm of ' .
+ $to . ']';
+ } elsif ($to eq '') {
+ print '\node [phi-arrow, right=.6cm of ' .
+ $from . ']';
+ } else {
+ print '\node [phi-arrow] at ($(' .
+ $from . ')!0.5!(' . $to . ')$)';
+ }
+ print '{}';
+ } elsif (index($head, '!') >= 0) {
+ my ($v, $marker) = split (/!/, $head);
+ print '\node [phi-marker, left=.6cm of ' .
+ $v . ']{' . fmt($marker) . '}';
+ } else {
print '\node[';
if (exists $opts{'xy'}) {
my ($v, $right, $down) = split(/,/, $opts{'xy'});
- print ',below right=';
- print $down;
- print 'cm and ';
- print $right;
- print 'cm of ';
- print $v;
+ my $loc = '';
+ if ($down > 0) {
+ $loc = 'below ';
+ } elsif ($down < 0) {
+ $loc = 'above ';
+ }
+ if ($right > 0) {
+ $loc = $loc . 'right';
+ } elsif ($right < 0) {
+ $loc = $loc . 'left';
+ }
+ print ',' . $loc . '=';
+ print abs(num($down)) . 'cm and ' .
+ abs(num($right)) . 'cm of ' . $v;
}
if (exists $opts{'data'}) {
print ',phi-data';
if (not $opts{'data'} eq '') {
my $d = $opts{'data'};
if (index($d, '|') == -1) {
- $d = '\textnormal{\texttt{' . $d . '}}';
+ $d = '$\Delta\phiDotted\text{' .
+ '\textnormal{\texttt{' . fmt($d) . '}}}$';
+ } else {
+ $d = fmt($d);
}
$opts{'box'} = $d;
}
@@ -237,7 +312,9 @@ foreach my $c (@cmds) {
if (not $opts{'atom'} eq '') {
my $a = $opts{'atom'};
if (index($a, '$') == -1) {
- $a = '$' . $a . '$';
+ $a = '$\lambda\phiDotted{}' . fmt($a) . '$';
+ } else {
+ $a = fmt($a);
}
$opts{'box'} = $a;
}
@@ -247,10 +324,13 @@ foreach my $c (@cmds) {
print ']';
print ' (', $head, ')';
print ' {$';
- if ($head eq 'v0') {
+ if (index($head, 'v0') == 0) {
print '\Phi';
} else {
- print 'v_', substr($head, 1);
+ $name = $head;
+ $name =~ s/^v/v_/g;
+ $name =~ s/[^0-9]$//g;
+ print $name;
}
print '$}';
if (exists $opts{'box'}) {
@@ -258,31 +338,6 @@ foreach my $c (@cmds) {
print $head, '.south east) {';
print $opts{'box'}, '}';
}
- } else {
- print '\draw[';
- if (exists $opts{'pi'}) {
- print ',phi-pi';
- if (not exists $opts{'a'}) {
- $opts{'a'} = '$\pi$';
- }
- }
- print ']';
- my ($from, $to) = split (/->/, $head);
- print ' (', $from, ') ';
- if (exists $opts{'bend'}) {
- print 'edge [bend right=', $opts{'bend'}, ']';
- } else {
- print '--';
- }
- if (exists $opts{'rho'} or exists $opts{'rrho'}) {
- print ' pic[sloped,phi-rho]{parallel arrow={';
- print '-' if not exists $opts{'rrho'};
- print '0.3,-0.15}}';
- }
- if (exists $opts{'a'}) {
- print ' node [phi-attr] {', $opts{'a'}, '}';
- }
- print ' (', $to, ')';
}
print ";\n";
}
@@ -312,9 +367,12 @@ print '\end{phicture}', "\n", '\endinput';
pics/parallel arrow/.style={
code={\draw[-latex,phi-rho] (##1) -- (-##1);}}]}%
{\end{tikzpicture}}
-\tikzstyle{transforms} = [fill=white!80!black, single arrow,
+\tikzstyle{phi-arrow} = [fill=white!80!black, single arrow,
minimum height=0.5cm, minimum width=0.5cm,
single arrow head extend=2mm]
+\tikzstyle{phi-marker} = [inner sep=0pt, minimum height=1.4em,
+ minimum width=1.4em, font={\small\color{white}\ttfamily},
+ fill=gray]
\tikzstyle{phi-thing} = [thick,inner sep=0pt,minimum height=2.4em,
draw,font={\small}]
\tikzstyle{phi-object} = [phi-thing,circle]
@@ -359,7 +417,8 @@ print '\end{phicture}', "\n", '\endinput';
\RequirePackage{hyperref}
\newcommand\phic{%
\ifdefined\anon%
- \anon[\texorpdfstring{$\alpha$}{a}-calculus]{\texorpdfstring{$\varphi$}{phi}-calculus}%
+ \anon[\texorpdfstring{$\alpha$}{a}-calculus]
+ {\texorpdfstring{$\varphi$}{phi}-calculus}%
\else%
\texorpdfstring{$\varphi$}{phi}-calculus%
\fi%
@@ -374,7 +433,8 @@ print '\end{phicture}', "\n", '\endinput';
}
\newcommand\phiConst{%
- \mathrel{\hspace{.15em}}\mapstochar\mathrel{\hspace{-.15em}}\mapsto}
+ \mathrel{\hspace{.15em}}%
+ \mapstochar\mathrel{\hspace{-.15em}}\mapsto}
\newcommand\phiWave{%
\mapstochar\mathrel{\mspace{0.45mu}}\leadsto}
@@ -382,7 +442,8 @@ print '\end{phicture}', "\n", '\endinput';
\RequirePackage{trimclip}
\RequirePackage{amsfonts}
\makeatletter
-\newcommand{\phiDotted}{\mapstochar\mathrel{\mathpalette\phiDotted@\relax}}
+\newcommand{\phiDotted}{%
+ \mapstochar\mathrel{\mathpalette\phiDotted@\relax}}
\newcommand{\phiDotted@}[2]{%
\begingroup
\settowidth{\dimen\z@}{$\m@th#1\rightarrow$}%
@@ -393,7 +454,8 @@ print '\end{phicture}', "\n", '\endinput';
{\resizebox{\dimen\z@}{\height}%
{$\m@th#1\dashrightarrow$}}%
\hss%
- \clipbox{{0.69\width} {-0.1\height} 0 {-\height}}{$\m@th#1\rightarrow$}%
+ \clipbox{{0.69\width} {-0.1\height} 0
+ {-\height}}{$\m@th#1\rightarrow$}%
}%
}%
\ht\z@=\dimen\tw@ \dp\z@=\z@%