From ecf5b52dbd9132da03ba53b3e1398d6c815ccf15 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 27 Oct 2022 20:07:43 +0000 Subject: eolang (27oct22) git-svn-id: svn://tug.org/texlive/trunk@64834 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/eolang/DEPENDS.txt | 6 +- Master/texmf-dist/doc/latex/eolang/README.md | 6 +- Master/texmf-dist/doc/latex/eolang/eolang.bib | 26 ++ Master/texmf-dist/doc/latex/eolang/eolang.pdf | Bin 591918 -> 957255 bytes Master/texmf-dist/doc/latex/eolang/main.bib | 26 -- Master/texmf-dist/source/latex/eolang/eolang.dtx | 474 ++++++++++++++++++----- Master/texmf-dist/tex/latex/eolang/eolang.sty | 276 +++++++++---- 7 files changed, 603 insertions(+), 211 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/eolang/eolang.bib delete mode 100644 Master/texmf-dist/doc/latex/eolang/main.bib (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/eolang/DEPENDS.txt b/Master/texmf-dist/doc/latex/eolang/DEPENDS.txt index ae6ed34e0b0..11d8637225e 100644 --- a/Master/texmf-dist/doc/latex/eolang/DEPENDS.txt +++ b/Master/texmf-dist/doc/latex/eolang/DEPENDS.txt @@ -4,4 +4,8 @@ hard amsfonts hard iexec hard pgf hard fancyvrb -hard pgfopts \ No newline at end of file +hard pgfopts +hard pdftexcmds +hard ifluatex +hard ifxetex +hard adjustbox diff --git a/Master/texmf-dist/doc/latex/eolang/README.md b/Master/texmf-dist/doc/latex/eolang/README.md index 257b0c163e3..86809ceb26f 100644 --- a/Master/texmf-dist/doc/latex/eolang/README.md +++ b/Master/texmf-dist/doc/latex/eolang/README.md @@ -1,5 +1,5 @@ [![l3build](https://github.com/objectionary/eolang.sty/actions/workflows/l3build.yml/badge.svg)](https://github.com/objectionary/eolang.sty/actions/workflows/l3build.yml) -[![CTAN](https://img.shields.io/ctan/v/eolang.sty)](https://ctan.org/pkg/eolang.sty) +[![CTAN](https://img.shields.io/ctan/v/eolang)](https://ctan.org/pkg/eolang) [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/objectionary/eolang.sty/blob/master/LICENSE.txt) This LaTeX package helps you write 𝜑-calculus formulas and @@ -16,12 +16,14 @@ and then use in the preamble: \begin{document} \begin{phiquation} x -> [ - \varphi -> |foo|(5), + @ -> |foo|(5), y -> [ \lambda -> M_1 ]]. \end{phiquation} \end{document} ``` +Otherwise, you can download [`eolang.sty`](https://raw.githubusercontent.com/objectionary/eolang.sty/gh-pages/eolang/eolang.sty) and add to your project. + If you want to contribute yourself, make a fork, then create a branch, then run `l3build ctan` in the root directory. It should compile everything without errors. If not, submit an issue and wait. diff --git a/Master/texmf-dist/doc/latex/eolang/eolang.bib b/Master/texmf-dist/doc/latex/eolang/eolang.bib new file mode 100644 index 00000000000..34ca47a8f28 --- /dev/null +++ b/Master/texmf-dist/doc/latex/eolang/eolang.bib @@ -0,0 +1,26 @@ +@misc{bugayenko2021eolang, + title={EOLANG and $\varphi$-calculus}, + author={Yegor Bugayenko}, + year={2021}, + eprint={2111.13384}, + archivePrefix={arXiv}, + primaryClass={cs.PL} +} + +@misc{bugayenko2022origins, + title={On the Origins of Objects by Means of Careful Selection}, + author={Yegor Bugayenko}, + year={2022}, + eprint={2206.02585}, + archivePrefix={arXiv}, + primaryClass={cs.PL} +} + +@misc{kudasov2021, + author = {Kudasov, Nikolai and Kim, Violetta}, + title = {$\varphi$-calculus: a purely object-oriented calculus of decorated objects}, + year = 2022, + eprint={2204.07454}, + archivePrefix={arXiv}, + primaryClass={cs.PL} +} diff --git a/Master/texmf-dist/doc/latex/eolang/eolang.pdf b/Master/texmf-dist/doc/latex/eolang/eolang.pdf index 9d25d909818..7bc02804788 100644 Binary files a/Master/texmf-dist/doc/latex/eolang/eolang.pdf and b/Master/texmf-dist/doc/latex/eolang/eolang.pdf differ diff --git a/Master/texmf-dist/doc/latex/eolang/main.bib b/Master/texmf-dist/doc/latex/eolang/main.bib deleted file mode 100644 index 34ca47a8f28..00000000000 --- a/Master/texmf-dist/doc/latex/eolang/main.bib +++ /dev/null @@ -1,26 +0,0 @@ -@misc{bugayenko2021eolang, - title={EOLANG and $\varphi$-calculus}, - author={Yegor Bugayenko}, - year={2021}, - eprint={2111.13384}, - archivePrefix={arXiv}, - primaryClass={cs.PL} -} - -@misc{bugayenko2022origins, - title={On the Origins of Objects by Means of Careful Selection}, - author={Yegor Bugayenko}, - year={2022}, - eprint={2206.02585}, - archivePrefix={arXiv}, - primaryClass={cs.PL} -} - -@misc{kudasov2021, - author = {Kudasov, Nikolai and Kim, Violetta}, - title = {$\varphi$-calculus: a purely object-oriented calculus of decorated objects}, - year = 2022, - eprint={2204.07454}, - archivePrefix={arXiv}, - primaryClass={cs.PL} -} diff --git a/Master/texmf-dist/source/latex/eolang/eolang.dtx b/Master/texmf-dist/source/latex/eolang/eolang.dtx index 1fabdd62821..c277d02c14c 100644 --- a/Master/texmf-dist/source/latex/eolang/eolang.dtx +++ b/Master/texmf-dist/source/latex/eolang/eolang.dtx @@ -50,15 +50,17 @@ %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{eolang} %<*package> -[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] % %<*driver> \documentclass{ltxdoc} \usepackage[maxnames=1,minnames=1,maxbibnames=1,natbib=true,citestyle=authoryear,bibstyle=authoryear,doi=false,url=false,isbn=false,isbn=false]{biblatex} -\addbibresource{main.bib} +\addbibresource{eolang.bib} \usepackage[tt=false, type1=true]{libertine} \usepackage{microtype} +\AddToHook{env/verbatim/begin}{\microtypesetup{protrusion=false}} \usepackage{graphicx} +\usepackage{xcolor} \usepackage[runs=1,dtx]{docshots} \usepackage{eolang} \usepackage{href-ul} @@ -80,9 +82,10 @@ % % \maketitle % -% \textbf{NB!} +% \textbf{\color{red}NB!} % You must run \TeX{} processor with |--shell-escape| option % and you must have \href{https://www.perl.org}{Perl} installed. +% This package doesn't work on Windows. % \section{Introduction} % @@ -101,9 +104,8 @@ % ^ !-> $.b, % b -> [[ c -> |fn|(56), % @ -> |hello|($), -% \Delta ~> |01-FE-C3| ]]]], - -% x -> [[ \alpha_0 -> ? ]] +% \Delta ..> |01-FE-C3| ]]]],\\ +% x -> [[ \alpha_0 -> ? ]]. % \end{phiquation*} % \end{document} % \end{docshot} @@ -124,10 +126,10 @@ % (|\varnothing|), % \item ``|->|'' maps to ``$\mapsto$'' % (|\mapsto|), -% \item ``|!->|'' maps to ``$\mapstochar\relbar\mathrel{\mkern-12mu}\mapsto$'' -% (|\mapstochar\relbar\mathrel{\mkern-12mu}\mapsto|), -% \item ``|~>|'' maps to ``$\mapstochar\dashrightarrow$'' -% (|\mapstochar\dashrightarrow|), +% \item ``|!->|'' maps to ``$\phiConst$'' +% (|\phiConst|), +% \item ``|..>|'' maps to ``$\phiDotted$'' +% (|\phiDotted|), % \item ``|[[|'' maps to ``$\llbracket$'' % (|\llbracket|), % \item ``|]]|'' maps to ``$\rrbracket$'' @@ -148,15 +150,14 @@ % using the same simple plain-text notation: % \begin{docshot} % \documentclass{article} -% \usepackage[paperwidth=2in]{geometry} % \pagestyle{empty} % \usepackage{eolang} % \begin{document} -% A simple object -% \phiq{x -> [[@ -> y]]} -% is a decorator of -% the data object -% \phiq{y -> [[\Delta ~> 42]]}. +% A simple object \\ +% \phiq{x -> [[@ -> y]]} \\ +% is a decorator of \\ +% the data object \\ +% \phiq{y -> [[\Delta ..> 42]]}. % \end{document} % \end{docshot} @@ -198,72 +199,259 @@ % \item ``|pi|'' makes it dotted, with $\pi$ label. % \end{itemize} +% \DescribeMacro{\eolang} +% \DescribeMacro{\phic} +% There is also a no-argument command |\eolang| to help you print the name of +% \eolang{} language. It understands |anonymous| mode of \href{https://ctan.org/pkg/acmart}{acmart} and prints itself +% differently, to double-blind your paper. There is also |\phic| command to print +% the name of \phic{}, also sensitive to |anonymous| mode. +% \begin{docshot} +% \documentclass[anonymous]{acmart} +% \thispagestyle{empty} +% \usepackage{eolang} +% \begin{document} +% In our research we use \eolang{}, \\ +% an experimental object-oriented \\ +% dataflow language, and \phic{}, \\ +% its formal foundation. +% \end{document} +% \end{docshot} + +% \DescribeMacro{\phiConst} +% A simple commands is defined to help you render an arrow for a constant attribute. +% It is recommende not to use it directly, but use |!->| instead. However, if you +% want to use |\phiConst|, wrap it in |\mathrel| for better display: +% \begin{docshot} +% \documentclass{article} +% \pagestyle{empty} +% \usepackage{eolang} +% \begin{document} +% \phiq{[[ x \mathrel{\phiConst} y ]]} +% \end{document} +% \end{docshot} + +% \section{Package Options} + +% \DescribeMacro{tmpdir} +% The default location of temp files is |_eolang|. You can change this using |tmpdir| option: +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +\usepackage[tmpdir=/tmp/foo]{eolang} +\end{verbatim} +%\iffalse +% +%\fi + +% \section{More Examples} + +% The |phiquation| environment treats ends of line as signals to start +% new lines in the formula. If you don't want this to happen and want to parse +% the next line as the a continuation of the current line, you can use a single +% backslash as it's done here: +% \begin{docshot} +% \documentclass{article} +% \usepackage{amsmath} +% \usepackage{eolang} +% \pagestyle{empty} +% \begin{document} +% \begin{phiquation*} +% \dfrac \ +% {x->[[@->y]] \quad y->[[z->|42|]]} \ +% {x.z -> |42|} \ +% \text{\sffamily R1} +% \end{phiquation*} +% \end{document} +% \end{docshot} + +% The |phiquation| environment may be used together with \href{https://ctan.org/pkg/acmart}{acmart}: +% \begin{docshot} +% \documentclass{acmart} +% \usepackage{eolang} +% \thispagestyle{empty} +% \begin{document} +% \begin{phiquation*} +% x -> [[ +% y -> [[ +% z !-> $, f ..> ? ]]]],\\ +% \beta_1 := [ \psi -wait> ? ]. +% \end{phiquation*} +% \end{document} +% \end{docshot} + +% The |phiquation| environment will automatically align formulas by the first +% arrow, if there are only left-aligned formulas: +% \begin{docshot} +% \documentclass{acmart} +% \usepackage{eolang} +% \thispagestyle{empty} +% \begin{document} +% \begin{phiquation*} +% x(\pi) -> [[\lambda ..> f_1]], \\ +% x(a,b,c) -> [[ \alpha_0 -> ?, \ +% @ -> |hello|($) ]], \\ +% \Delta = |43-09|. +% \end{phiquation*} +% \end{document} +% \end{docshot} + % \StopEventually{} % \section{Implementation} +% \changes{0.0.1}{2022/10/15}{First draft.} -% First, we include a few packages: +% First, we include a few packages. +% We need \href{https://ctan.org/pkg/stmaryrd}{stmaryrd} for |\llbracket| and |\rrbracket| commands: % \begin{macrocode} \RequirePackage{stmaryrd} +% \end{macrocode} +% We need \href{https://ctan.org/pkg/amsmath}{amsmath} for |equation*| environment: +% \begin{macrocode} \RequirePackage{amsmath} -\RequirePackage{amssymb} -\RequirePackage{amsfonts} -\RequirePackage{iexec} +% \end{macrocode} +% We need \href{https://ctan.org/pkg/amssymb}{amssymb} for |\varnothing| command. We disable |\Bbbk| +% because it may conflict with some packages from \href{https://ctan.org/pkg/acmart}{acmart}: +% \begin{macrocode} +\let\Bbbk\relax\RequirePackage{amssymb} +% \end{macrocode} +% We need \href{https://ctan.org/pkg/fancyvrb}{fancyvrb} for |\VerbatimEnvironment| command: +% \begin{macrocode} \RequirePackage{fancyvrb} % \end{macrocode} +% We need \href{https://ctan.org/pkg/iexec}{iexec} for executing Perl scripts: +% \begin{macrocode} +\RequirePackage{iexec} +% \end{macrocode} -% \begin{macro}{\eolang@env} +% Then, we process package options: +% \changes{0.1.0}{2022/10/26}{Parsing of package options introduced.} +% \begin{macrocode} +\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} +% \end{macrocode} + +% Then, we make a directory where all temporary files will be kept: +% \begin{macrocode} +\iexec[null]{mkdir -p "\eolang@tmpdir/\jobname"}% +% \end{macrocode} + +% \begin{macro}{\eolang@mdfive} +% \changes{0.1.0}{2022/10/26}{New supplementary command added to calculate MD5 sum of a file.} +% Then, we define a command for MD5 hash calculating of a file: +% \begin{macrocode} +\RequirePackage{pdftexcmds} +\makeatletter\newcommand\eolang@mdfive[1]{\pdf@filemdfivesum{#1}}\makeatother +% \end{macrocode} +% \end{macro} + +% \begin{macro}{eolang-phi.pl} % \changes{0.0.2}{2022/10/21}{The symbols ``['' and ``]'' replaced with ``[['' and ``]]'' for abstract object brackets, because they conflicted with normal square brackets} % \changes{0.0.2}{2022/10/21}{New symbol added for basket slots} % \changes{0.0.2}{2022/10/21}{Parsing of symbols ``@,'' ``\^{},'' and ``\&'' enabled (varphi, rho, and sigma)} -% Then, we define |\eolang@env| supplementary command. -% It is implemented with the help of |\iexec| from -% \href{https://github.com/yegor256/iexec}{iexec} package: +% \changes{0.1.0}{2022/10/26}{A new Perl script "eolang-phi.pl" added for parsing of phi expressions.} +% Then, we create a Perl script for |phiquation| processing: % \begin{macrocode} -\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 +\makeatletter +\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 % \end{macrocode} % \end{macro} % \begin{macro}{phiquation} -% Then, we define |phiquation| and |phiquation*| environments: +% Then, we define |phiquation| and |phiquation*| environments through a supplementary +% |\eolang@process| command: % \begin{macrocode} -\makeatletter -\NewDocumentEnvironment{phiquation*}{b}{% - \eolang@env{equation*}{#1} -}{} -\NewDocumentEnvironment{phiquation}{b}{% - \eolang@env{equation}{#1} -}{} +\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 -\AddToHook{env/phiquation*/begin}{\obeylines\obeyspaces} -\AddToHook{env/phiquation/begin}{\obeylines\obeyspaces} % \end{macrocode} % \end{macro} @@ -271,42 +459,47 @@ % \changes{0.0.2}{2022/10/21}{Parsing of additional symbols enabled} % Then, we define |\phiq| command: % \begin{macrocode} -\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\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 % \end{macrocode} % \end{macro} -% \begin{macro}{Perl} +% \begin{macro}{eolang-sodg.pl} % \changes{0.0.2}{2022/10/24}{The Perl file now has a fixed name, which doesn't depend on the name of the TeX job. This file may be shared among jobs, no need to make it uniquely named.} -% Then, create a Perl script: +% \changes{0.1.0}{2022/10/26}{There are two Perl scripts now: one for phiquation, another one for sodg.} +% Then, we create a Perl script for |sodg| graphs processing: % \begin{macrocode} -\begin{VerbatimOut}{eolang.pl} -$tex = $ARGV[0]; +\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 = {}; @@ -380,10 +573,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 % \end{macrocode} % \end{macro} @@ -402,10 +598,10 @@ print '\end{phig}', "\n", '\endinput'; % \end{macrocode} % \end{macro} -% \begin{macro}{phig} -% Then, we define internal environment |phig|: +% \begin{macro}{phicture} +% Then, we define internal environment |phicture|: % \begin{macrocode} -\newenvironment{phig}% +\newenvironment{phicture}% {\noindent\begin{tikzpicture}[ ->,>=stealth',node distance=0,thick, pics/parallel arrow/.style={ @@ -438,14 +634,84 @@ print '\end{phig}', "\n", '\endinput'; % Then, create a new environment |sodg|, as suggested % \href{https://tex.stackexchange.com/questions/661056}{here}: % \begin{macrocode} -\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 +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\eolang} +% \changes{0.1.0}{2022/10/25}{New command "eolang" added to print the name of the language in both +% normal and anonymous mode of "acmart"} +% \begin{macrocode} +\makeatletter\newcommand\eolang{% + \ifdefined\anon% + \anon[XYZ]{{\sffamily EO}}% + \else% + {\sffamily EO}% + \fi% +}\makeatother +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\phic} +% \changes{0.1.0}{2022/10/25}{New command "phic" prints the name of $\varphi$-calculus in both +% normal and anonymous mode of "acmart"} +% \begin{macrocode} +\makeatletter\newcommand\phic{% + \ifdefined\anon% + \anon[$\alpha$-calculus]{$\varphi$-calculus}% + \else% + $\varphi$-calculus% + \fi% +}\makeatother +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\phiConst} +% \changes{0.1.0}{2022/10/26}{New command "phiConst" added to denote a link to a constant attribute.} +% Then, we define a command to render an arrow for a constant attribute, +% as suggested \href{https://tex.stackexchange.com/questions/663121}{here}: +% \begin{macrocode} +\newcommand\phiConst{% + \mathrel{\hspace{.15em}}\mapstochar\mathrel{\hspace{-.15em}}\mapsto} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\phiDotted} +% \changes{0.1.0}{2022/10/27}{New command "phiDotted" added to denote a link to a special attribute.} +% Then, we define a command to render an arrow for a special attribute, +% as suggested \href{https://tex.stackexchange.com/questions/663176}{here}: +% \begin{macrocode} +\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 % \end{macrocode} % \end{macro} 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 -- cgit v1.2.3