summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/eolang
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/eolang')
-rw-r--r--Master/texmf-dist/tex/latex/eolang/eolang.sty276
1 files changed, 198 insertions, 78 deletions
diff --git a/Master/texmf-dist/tex/latex/eolang/eolang.sty b/Master/texmf-dist/tex/latex/eolang/eolang.sty
index ef1b1b19e3c..ad40f34c039 100644
--- a/Master/texmf-dist/tex/latex/eolang/eolang.sty
+++ b/Master/texmf-dist/tex/latex/eolang/eolang.sty
@@ -31,7 +31,14 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{eolang}
-[2022-10-25 0.0.2 Formulas and Graphs for EO Programming Language]
+[2022-10-27 0.1.0 Formulas and Graphs for EO Programming Language]
+
+
+
+
+
+
+
@@ -43,81 +50,147 @@
\RequirePackage{stmaryrd}
\RequirePackage{amsmath}
-\RequirePackage{amssymb}
-\RequirePackage{amsfonts}
-\RequirePackage{iexec}
+\let\Bbbk\relax\RequirePackage{amssymb}
\RequirePackage{fancyvrb}
+\RequirePackage{iexec}
-\makeatletter\newcommand\eolang@env[2]{
- \iexec[trace]{
- /bin/echo -n '\\begin{#1}\\begin{split} &'
- &&
- /bin/echo -n '\detokenize{#2}'
- | perl -pe 's/^\\r\\+//g'
- | perl -pe 's/\\r\\+$//g'
- | perl -pe 's/\\?/\\\\varnothing/g'
- | perl -pe 's/@/\\\\varphi/g'
- | perl -pe 's/&/\\\\sigma/g'
- | perl -pe 's/\\^/\\\\rho/g'
- | perl -pe 's/\\$/\\\\xi/g'
- | perl -pe 's/-([a-z]+)>/\\\\xrightarrow{\\\\text{\\\\sffamily\\\\scshape \\1}}/g'
- | perl -pe 's/!->/\\\\mapstochar\\\\relbar\\\\mathrel{\\\\mkern-12mu}\\\\mapsto/g'
- | perl -pe 's/->/\\\\mapsto/g'
- | perl -pe 's/:=/\\\\vDash/g'
- | perl -pe 's/\unexpanded{~}>/\\\\mapstochar\\\\dashrightarrow/g'
- | perl -pe 's/\\|([^\\|]+)\\|/\\\\texttt{\\1}/g'
- | perl -pe 's/\\[\\[/\\\\llbracket/g'
- | perl -pe 's/\\]\\]/\\\\rrbracket/g'
- | perl -pe 's/\\r\\r/\\\\\\\\ \&/g'
- | perl -pe 's/\\r/\\\\\\\\[-4pt] \&/g'
- | perl -pe 's/([^& ]) {2}([^ ])/\\1 \\2/g'
- | perl -pe 's/ {2}/\\\\quad{}/g'
- &&
- /bin/echo -n '\\end{split}\\end{#1}\\endinput'
- }%
-}\makeatother
+\RequirePackage{pgfopts}
+\RequirePackage{ifluatex}
+\RequirePackage{ifxetex}
+\pgfkeys{
+ /eolang/.cd,
+ tmpdir/.store in=\eolang@tmpdir,
+ tmpdir/.default=_eolang\ifxetex-xe\else\ifluatex-lua\fi\fi,
+ tmpdir
+}
+\ProcessPgfOptions{/eolang}
+
+\iexec[null]{mkdir -p "\eolang@tmpdir/\jobname"}%
+
+\RequirePackage{pdftexcmds}
+\makeatletter\newcommand\eolang@mdfive[1]{\pdf@filemdfivesum{#1}}\makeatother
\makeatletter
-\NewDocumentEnvironment{phiquation*}{b}{%
- \eolang@env{equation*}{#1}
-}{}
-\NewDocumentEnvironment{phiquation}{b}{%
- \eolang@env{equation}{#1}
-}{}
+\begin{VerbatimOut}{\eolang@tmpdir/eolang-phi.pl}
+$env = $ARGV[0];
+open(my $fh, '<', $ARGV[1]);
+my $tex; { local $/; $tex = <$fh>; }
+print '% This file is auto-generated', "\n";
+print '% There are ', length($tex),
+ ' chars in the input: ', $ARGV[1], "\n";
+print '% ---', "\n";
+if (index($tex, "\t") > 0) {
+ print "TABS are prohibited!";
+ exit 1;
+}
+my @lines = split (/\n/g, $tex);
+foreach my $t (@lines) {
+ print '% ', $t, "\n";
+}
+print '% ---', "\n";
+if ($env eq 'phiq') {
+ print '$';
+} else {
+ print '\begin{', $env, '}\begin{split}';
+}
+$tex =~ s/^\s+|\s+$//g;
+if ($env ne 'phiq') {
+ $tex =~ s/\s+\\\n\s*//g;
+ $tex =~ s/\\\\\n/\n\n/g;
+}
+$tex =~ s/\?/\\varnothing{}/g;
+$tex =~ s/@/\\varphi{}/g;
+$tex =~ s/&/\\sigma{}/g;
+$tex =~ s/\^/\\rho{}/g;
+$tex =~ s/\$/\\xi{}/g;
+$tex =~ s/-([a-z]+)>/\\mathrel{\\xrightarrow{\\text{\\sffamily\\scshape \1}}}/g;
+$tex =~ s/!->/\\mathrel{\\phiConst}/g;
+$tex =~ s/->/\\mathrel{\\mapsto}/g;
+$tex =~ s/:=/\\mathrel{\\vDash}/g;
+$tex =~ s/..>/\\mathrel{\\phiDotted}/g;
+$tex =~ s/\|([^\|]+)\|/\\texttt{\1}{}/g;
+$tex =~ s/\[\[/\\llbracket\\mathrel{}/g;
+$tex =~ s/\]\]/\\mathrel{}\\rrbracket{}/g;
+if ($env ne 'phiq') {
+ $tex =~ s/\n\n/\\\\&/g;
+ $tex =~ s/\n/\\\\[-4pt]&/g;
+ $tex =~ s/([^&\s])\s{2}([^\s])/\1 \2/g;
+ $tex =~ s/\s{2}/ \\quad{}/g;
+ my @leads = $tex =~ /&[^\s]+\s/g;
+ my @eols = $tex =~ /&/g;
+ $tex = '&' . $tex;
+ if (0+@leads == 0+@eols && 0+@eols > 0) {
+ $tex =~ s/&([^\s]+)\s/\1&/g;
+ }
+}
+print $tex;
+if ($env eq 'phiq') {
+ print '$';
+} else {
+ print '\end{split}\end{', $env, '}';
+}
+print '\endinput', "\n";
+\end{VerbatimOut}
+\message{eolang: File with Perl script
+ '\eolang@tmpdir/eolang-phi.pl' saved^^J}%
+\iexec[trace,null]{perl -pi -e 's/(\\\\[a-zA-Z])\\s+/\\1/g'
+ "\eolang@tmpdir/eolang-phi.pl"}
\makeatother
-\AddToHook{env/phiquation*/begin}{\obeylines\obeyspaces}
-\AddToHook{env/phiquation/begin}{\obeylines\obeyspaces}
-
-\newcommand\phiq[1]{
- \iexec[trace]{
- /bin/echo -n '$'
- &&
- /bin/echo -n '\detokenize{#1}'
- | perl -pe 's/\\^/\\\\rho/g'
- | perl -pe 's/\\$/\\\\xi/g'
- | perl -pe 's/&/\\\\sigma/g'
- | perl -pe 's/\\?/\\\\varnothing/g'
- | perl -pe 's/@/\\\\varphi/g'
- | perl -pe 's/!->/\\\\mapstochar\\\\relbar\\\\mathrel{\\\\mkern-12mu}\\\\mapsto/g'
- | perl -pe 's/->/\\\\mapsto/g'
- | perl -pe 's/-([a-z]+)>/\\\\xrightarrow{\\\\text{\\\\sffamily\\\\scshape \\1}}/g'
- | perl -pe 's/\unexpanded{~}>/\\\\mapstochar\\\\dashrightarrow/g'
- | perl -pe 's/:=/\\\\vDash/g'
- | perl -pe 's/\\[\\[/\\\\llbracket/g'
- | perl -pe 's/\\]\\]/\\\\rrbracket/g'
- &&
- /bin/echo -n '$\\endinput'
- }%
+
+\makeatletter\newcommand\eolang@process[1]{
+ \def\hash{\eolang@mdfive
+ {\eolang@tmpdir/\jobname/phiquation.tex}}%
+ \iexec[null]{cp "\eolang@tmpdir/\jobname/phiquation.tex"
+ "\eolang@tmpdir/\jobname/\hash.tex"}%
+ \iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-post.tex]{
+ perl "\eolang@tmpdir/eolang-phi.pl"
+ '#1'
+ "\eolang@tmpdir/\jobname/\hash.tex"}%
}
+\newenvironment{phiquation*}%
+{\VerbatimEnvironment\begin{VerbatimOut}
+ {\eolang@tmpdir/\jobname/phiquation.tex}}
+{\end{VerbatimOut}\eolang@process{equation*}}
+\newenvironment{phiquation}%
+{\VerbatimEnvironment\begin{VerbatimOut}
+ {\eolang@tmpdir/\jobname/phiquation.tex}}
+{\end{VerbatimOut}\eolang@process{equation}}
+\makeatother
-\begin{VerbatimOut}{eolang.pl}
-$tex = $ARGV[0];
+\makeatletter\newcommand\phiq[1]{
+ \iexec[trace,quiet,stdout=\eolang@tmpdir/\jobname/phiq.tex]{
+ /bin/echo '\detokenize{#1}'}
+ \def\hash{\eolang@mdfive
+ {\eolang@tmpdir/\jobname/phiq.tex}}%
+ \iexec[null]{cp "\eolang@tmpdir/\jobname/phiq.tex"
+ "\eolang@tmpdir/\jobname/\hash.tex"}%
+ \iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-post.tex]{
+ perl \eolang@tmpdir/eolang-phi.pl 'phiq'
+ "\eolang@tmpdir/\jobname/\hash.tex"}%
+}\makeatother
+
+\makeatletter
+\begin{VerbatimOut}{\eolang@tmpdir/eolang-sodg.pl}
+open(my $fh, '<', $ARGV[0]);
+my $tex; { local $/; $tex = <$fh>; }
+print '% This file is auto-generated', "\n";
+print '% There are ', length($tex),
+ ' chars in the input: ', $ARGV[0], "\n";
+print '% ---', "\n";
+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/\r\s+/\r/g;
+$tex =~ s/\n\s+/\n/g;
$tex =~ s/\|([^\|]+)\|/\\texttt{\1}/g;
-my @cmds = split (/\r/g, $tex);
-print '\begin{phig}', "\n";
+my @cmds = split (/\n/g, $tex);
+foreach my $t (@cmds) {
+ print '% ', $t, "\n";
+}
+print '% ---', "\n";
+print '\begin{phicture}', "\n";
foreach my $c (@cmds) {
my ($head, $tail) = split (/ /, $c, 2);
my %opts = {};
@@ -191,10 +264,13 @@ foreach my $c (@cmds) {
}
print ";\n";
}
-print '\end{phig}', "\n", '\endinput';
+print '\end{phicture}', "\n", '\endinput';
\end{VerbatimOut}
-\message{^^Jeolang: File with Perl script (eolang.pl) saved^^J}%
-\iexec[trace,null]{perl -pi -e 's/(\\\\[a-zA-Z])\\s+/\\1/g' eolang.pl}
+\message{eolang: File with Perl script
+ '\eolang@tmpdir/eolang-sodg.pl' saved^^J}%
+\iexec[trace,null]{perl -pi -e 's/(\\\\[a-zA-Z])\\s+/\\1/g'
+ "\eolang@tmpdir/eolang-sodg.pl"}
+\makeatother
\RequirePackage{tikz}
\usetikzlibrary{arrows}
@@ -206,7 +282,7 @@ print '\end{phig}', "\n", '\endinput';
\usetikzlibrary{calc}
\usetikzlibrary{shapes.arrows}
-\newenvironment{phig}%
+\newenvironment{phicture}%
{\noindent\begin{tikzpicture}[
->,>=stealth',node distance=0,thick,
pics/parallel arrow/.style={
@@ -232,14 +308,58 @@ print '\end{phig}', "\n", '\endinput';
above=2pt,sloped/.append style={transform shape},
font={\scriptsize},color=black]
-\NewDocumentEnvironment{sodg}{b}{%
- \catcode`\ =10 %
- \catcode`\^^M=5 %
- \iexec[trace,stdout=\jobname.tex.eolang]{
- perl eolang.pl '\detokenize{#1}'}%
-}{}
-\AddToHook{env/sodg/before}{\bgroup\obeylines\obeyspaces}
-\AddToHook{env/sodg/after}{\egroup}
+\makeatletter\newenvironment{sodg}%
+{\VerbatimEnvironment\begin{VerbatimOut}
+ {\eolang@tmpdir/\jobname/sodg.tex}}
+{\end{VerbatimOut}%
+ \def\hash{\eolang@mdfive
+ {\eolang@tmpdir/\jobname/sodg.tex}}%
+ \iexec[null]{cp "\eolang@tmpdir/\jobname/sodg.tex"
+ "\eolang@tmpdir/\jobname/\hash.tex"}%
+ \iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-post.tex]{
+ perl "\eolang@tmpdir/eolang-sodg.pl"
+ "\eolang@tmpdir/\jobname/\hash.tex"}%
+}\makeatother
+
+\makeatletter\newcommand\eolang{%
+ \ifdefined\anon%
+ \anon[XYZ]{{\sffamily EO}}%
+ \else%
+ {\sffamily EO}%
+ \fi%
+}\makeatother
+
+\makeatletter\newcommand\phic{%
+ \ifdefined\anon%
+ \anon[$\alpha$-calculus]{$\varphi$-calculus}%
+ \else%
+ $\varphi$-calculus%
+ \fi%
+}\makeatother
+
+\newcommand\phiConst{%
+ \mathrel{\hspace{.15em}}\mapstochar\mathrel{\hspace{-.15em}}\mapsto}
+
+\RequirePackage{trimclip}
+\RequirePackage{amsfonts}
+\makeatletter
+\newcommand{\phiDotted}{\mapstochar\mathrel{\mathpalette\phiDotted@\relax}}
+\newcommand{\phiDotted@}[2]{%
+ \begingroup
+ \settowidth{\dimen\z@}{$\m@th#1\rightarrow$}%
+ \settoheight{\dimen\tw@}{$\m@th#1\rightarrow$}%
+ \sbox\z@{%
+ \makebox[\dimen\z@][s]{%
+ \clipbox{0 0 {0.4\width} 0}%
+ {\resizebox{\dimen\z@}{\height}%
+ {$\m@th#1\dashrightarrow$}}%
+ \hss%
+ \clipbox{{0.69\width} {-0.1\height} 0 {-\height}}{$\m@th#1\rightarrow$}%
+ }%
+ }%
+ \ht\z@=\dimen\tw@ \dp\z@=\z@%
+ \box\z@%
+ \endgroup}\makeatother