summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/eolang/eolang.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/eolang/eolang.dtx')
-rw-r--r--macros/latex/contrib/eolang/eolang.dtx94
1 files changed, 71 insertions, 23 deletions
diff --git a/macros/latex/contrib/eolang/eolang.dtx b/macros/latex/contrib/eolang/eolang.dtx
index 74c346d52f..ee68942161 100644
--- a/macros/latex/contrib/eolang/eolang.dtx
+++ b/macros/latex/contrib/eolang/eolang.dtx
@@ -50,10 +50,11 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{eolang}
%<*package>
-[2022-11-16 0.6.0 Formulas and Graphs for EO Programming Language]
+[2022-11-18 0.7.0 Formulas and Graphs for EO Programming Language]
%</package>
%<*driver>
\documentclass{ltxdoc}
+\usepackage[T1]{fontenc}
\usepackage[maxnames=1,minnames=1,maxbibnames=1,natbib=true,citestyle=authoryear,bibstyle=authoryear,doi=false,url=false,isbn=false,isbn=false]{biblatex}
\addbibresource{eolang.bib}
\usepackage[tt=false, type1=true]{libertine}
@@ -100,12 +101,12 @@
% \usepackage{eolang}
% \begin{document}
% \begin{phiquation*}
-% a -> [[ % it's abstract!
-% ^ !-> $.b.^{^2}, 0/t-> TRUE,
-% b -> [[ *-> |fn|(56),
-% @ -> |hello|($),
-% \Delta ..> 01-FE-C3 ]]]],\\
-% x -> [[ \alpha_0 -> ? ]].
+% app -> [[ % it's abstract!
+% ^ !-> $.b.^{^2}, 0/t~> TRUE,
+% b -> [[ *-> fn(56),
+% @ -> Q.hello.bye($),
+% D> 01-FE-C3 ]]]],\\
+% x -> [[ \lambda ..> ? ]].
% \end{phiquation*}
% \end{document}
% \end{docshot}
@@ -124,6 +125,8 @@
% (|\sigma|),
% \item ``|?|'' maps to ``$\varnothing$''
% (|\varnothing|),
+% \item ``|Q|'' maps to ``$\Phi$''
+% (|\Phi|),
% \item ``|->|'' maps to ``$\mapsto$''
% (|\mapsto|),
% \item ``|~>|'' maps to ``$\phiWave$''
@@ -132,11 +135,15 @@
% (|\phiConst|),
% \item ``|..>|'' maps to ``$\phiDotted$''
% (|\phiDotted|),
+% \item ``|D>|'' maps to ``$\Delta\phiDotted$''
+% (|\Delta ..>|),
+% \item ``|L>|'' maps to ``$\lambda\phiDotted$''
+% (|\lambda ..>|),
% \item ``|[[|'' maps to ``$\llbracket$''
% (|\llbracket|),
% \item ``|]]|'' maps to ``$\rrbracket$''
% (|\rrbracket|),
-% \item ``$\vert$|abc|$\vert$'' maps to ``\texttt{abc}''
+% \item ``\texttt{\textbar{abc}\textbar}'' maps to ``\texttt{abc}''
% (|\texttt{abc}|).
% \end{itemize}
% Also, a few symbols are supported for $\varphi$PU architecture:
@@ -153,16 +160,20 @@
% You can append a slash and a title to the number of an attribute, such as |0/g->x|.
% this will render as \phiq{0/g->x}. You can use fixed-width words too, for example
-% \verb=\phiq{0/|foo|->x}= will render as ``\phiq{0/|foo|->x}''. It's also possible
+% \verb=\phiq{0/|f|->x}= will render as ``\phiq{0/|f|->x}''. It's also possible
% to use an asterix instead of a number, such that |\phiq{*/g->x}| renders as ``\phiq{*/g->x}''
% Numbers are automatically converted to fixed-width font, no need to always decorate them with vertical bars.
% |TRUE| and |FALSE| are automatically converted to fixed-width font too.
+% Object names are automatically converted to fixed-width font too, if they have more than one letter.
+
+% Texts in double quotes are automatically converted to fixed-width font too.
+
% \DescribeMacro{\phiq}
% The command |\phiq| lets you inline a $\varphi$-calculus expressions
-% using the same simple plain-text notation:
+% using the same simple plain-text notation. You can use dollar sign directly too:
% \docshotOptions{firstline=4,lastline=10}
% \begin{docshot}
% \documentclass{article}
@@ -173,7 +184,7 @@
% \phiq{x -> [[@ -> y]]} \\
% is a decorator of
% the data object \\
-% \phiq{y -> [[\Delta ..> 42]]}.
+% $y -> [[\Delta ..> 42]]$.
% \end{document}
% \end{docshot}
@@ -314,6 +325,18 @@
%</verb>
%\fi
+% \DescribeMacro{nodollar}
+% You may disable special treatment of the dollar sign:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\usepackage[nodollar]{eolang}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+
% \section{More Examples}
% The |phiquation| environment treats ends of line as signals to start
@@ -348,7 +371,7 @@
% \begin{phiquation*}
% \dfrac{\begin{split}
% x->[[@->y, z->42,
-% 0/g->?, 1/|foo|->42]]
+% 0/g->?, 1/foo->42]]
% \end{split}}{\begin{split}
% x->[[@->y, z->?, f ~> |pi|(
% 0->[[ \psi !-> |hello|(12) ]],
@@ -484,7 +507,7 @@
% v2 xy:v0,0,1
% v0->v2 a:y
% v3 xy:v0,1,1
-% v0->v3 a:z
+% v0->v3 a:\psi{}
% v3->v1 a:f bend:-75 break:30
% \end{sodg}
% \end{document}
@@ -588,7 +611,11 @@
% \changes{0.5.0}{2022/11/11}{Automated formatting of \texttt{TRUE} and \texttt{FALSE} added.}
% \changes{0.5.0}{2022/11/13}{A new syntax introduced for \texttt{\char`\\alpha}-attributes: \texttt{0->}.}
% \changes{0.5.0}{2022/11/14}{It's possible to use double names for attributes, such as \texttt{0/g->}.}
-% Then, we create a Perl script for |phiquation| processing using |VerbatimOut| from
+% \changes{0.7.0}{2022/11/17}{Object names are automatically converted to \texttt{\char`\\texttt}, provided their names include two or more symbols.}
+% \changes{0.7.0}{2022/11/17}{Text in quotes is automatically converted to \texttt{\char`\\texttt}.}
+% \changes{0.7.0}{2022/11/17}{New syntax sugar constructs added: \texttt{D>} and \texttt{L>} for \texttt{\char`\\Delta} and \texttt{\char`\\lambda} with a dotted arrow respectively.}
+% \changes{0.7.0}{2022/11/18}{New syntax sugar for $\Phi$, just using capital ``\texttt{Q}'' is enough.}
+% Then, we create a Perl script for |phiquation| processing using |VerbatimOut| environment from
% \href{https://ctan.org/pkg/fancyvrb}{fancyvrb}:
% \begin{macrocode}
\makeatletter
@@ -618,6 +645,11 @@ if ($env ne 'phiq') {
$tex =~ s/\n*(\\label\{[^\}]+\})\n*/\1/g;
}
$tex =~ s/&/\\sigma{}/g;
+$tex =~ s/([^\\{a-z0-9]|^)Q(?![a-z0-9])/\1\\Phi{}/g;
+$tex =~ s/([^\\{a-z0-9]|^)D>/\1\\Delta{}..>/g;
+$tex =~ s/([^\\{a-z0-9]|^)L>/\1\\lambda{}..>/g;
+$tex =~ s/"([^"]+)"/|"\1"|/g;
+$tex =~ s/([ )(.>\/]|^)([a-z0-9]{2,})(?=[ )(.-])/\1|\2|/g;
$tex =~ s/([^^_]|^)([0-9]+|\*)\/(\\?[a-z]+|\|[a-z]+\|)
(->|\.\.>|~>|:=|!->)/\1\\alpha_{\2}\\vert{}\3\\space{}\4/xg;
$tex =~ s/([^^_]|^)([0-9]+|\*)
@@ -684,8 +716,6 @@ print '\endinput';
\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}
@@ -733,14 +763,30 @@ print '\endinput';
{\eolang@tmpdir/\jobname/phiq.tex}}%
\iexec[null]{cp "\eolang@tmpdir/\jobname/phiq.tex"
"\eolang@tmpdir/\jobname/\hash.tex"}%
+ \ifdefined\eolang@nodollar\else\catcode`\$=3 \fi%
\iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-post.tex]{
perl \eolang@tmpdir/eolang-phi.pl 'phiq'
"\eolang@tmpdir/\jobname/\hash.tex"
\ifdefined\eolang@nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi}%
+ \ifdefined\eolang@nodollar\else\catcode`\$\active\fi%
}\makeatother
% \end{macrocode}
% \end{macro}
+% \begin{macro}{nodollar}
+% \changes{0.7.0}{2022/11/18}{Now it is possible to use dollar sign instead of \texttt{\char`\\phiq}.}
+% Then, we redefine dollar sign:
+% \begin{macrocode}
+\ifdefined\eolang@nodollar\else
+ \begingroup
+ \catcode`\$=\active
+ \protected\gdef$#1${\phiq{#1}}
+ \endgroup
+ \AtBeginDocument{\catcode`\$=\active}
+\fi
+% \end{macrocode}
+% \end{macro}
+
% \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.}
% \changes{0.1.0}{2022/10/26}{There are two Perl scripts now: one for \texttt{phiquation}, another one for \texttt{sodg}.}
@@ -799,7 +845,7 @@ foreach my $t (split (/\n/g, $tex)) {
print "% ---\n";
$tex =~ s/\\\\/\n/g;
$tex =~ s/\\\n//g;
-$tex =~ s/(\\[a-zA-Z]+) +/\1/g;
+$tex =~ s/(\\[a-zA-Z]+)\s+/\1/g;
$tex =~ s/\n{2,}/\n/g;
my @cmds = split(/\n/g, $tex);
print '% --- before processing:' . "\n";
@@ -1013,8 +1059,6 @@ print '\endinput';
\end{VerbatimOut}
\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}
@@ -1028,7 +1072,7 @@ print '\endinput';
% \end{macro}
% \begin{macro}{tikz}
-% Then, we include |tikz| package and its libraries:
+% Then, we include \href{https://ctan.org/pkg/tikz}{tikz} package and its libraries:
% \begin{macrocode}
\RequirePackage{tikz}
\usetikzlibrary{arrows}
@@ -1131,7 +1175,7 @@ print '\endinput';
% \begin{macro}{sodg}
% \changes{0.0.2}{2022/10/20}{The environment \texttt{phigure} renamed to \texttt{sodg} for the sake of better semantic. The graph in the picture is solely a SODG graph, that's why the name \texttt{sodg} is better.}
-% Then, create a new environment |sodg|, as suggested
+% Then, we create a new environment |sodg|, as suggested
% \href{https://tex.stackexchange.com/questions/661056}{here}:
% \begin{macrocode}
\makeatletter\newenvironment{sodg}%
@@ -1144,10 +1188,12 @@ print '\endinput';
{\eolang@tmpdir/\jobname/sodg.tex}}%
\iexec[null]{cp "\eolang@tmpdir/\jobname/sodg.tex"
"\eolang@tmpdir/\jobname/\hash.tex"}%
+ \catcode`\$=3 %
\iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-post.tex]{
perl "\eolang@tmpdir/eolang-sodg.pl"
"\eolang@tmpdir/\jobname/\hash.tex"
\ifdefined\eolang@nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi}%
+ \catcode`\$\active%
\setcounter{FancyVerbLine}{\value{eolang@lineno}}%
}\makeatother
% \end{macrocode}
@@ -1249,7 +1295,7 @@ print '\endinput';
\newcommand{\phiDotted}{%
\mapstochar\mathrel{\mathpalette\phiDotted@\relax}}
\newcommand{\phiDotted@}[2]{%
- \begingroup
+ \begingroup%
\settowidth{\dimen\z@}{$\m@th#1\rightarrow$}%
\settoheight{\dimen\tw@}{$\m@th#1\rightarrow$}%
\sbox\z@{%
@@ -1264,7 +1310,9 @@ print '\endinput';
}%
\ht\z@=\dimen\tw@ \dp\z@=\z@%
\box\z@%
- \endgroup}\makeatother
+ \endgroup%
+}
+\makeatother
% \end{macrocode}
% \end{macro}