texlive[65131] Master/texmf-dist: eolang (28nov22)
commits+karl at tug.org
commits+karl at tug.org
Mon Nov 28 21:59:47 CET 2022
Revision: 65131
http://tug.org/svn/texlive?view=revision&revision=65131
Author: karl
Date: 2022-11-28 21:59:47 +0100 (Mon, 28 Nov 2022)
Log Message:
-----------
eolang (28nov22)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/eolang/README.md
trunk/Master/texmf-dist/doc/latex/eolang/eolang.pdf
trunk/Master/texmf-dist/source/latex/eolang/eolang.dtx
trunk/Master/texmf-dist/tex/latex/eolang/eolang.sty
Modified: trunk/Master/texmf-dist/doc/latex/eolang/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/eolang/README.md 2022-11-28 16:12:15 UTC (rev 65130)
+++ trunk/Master/texmf-dist/doc/latex/eolang/README.md 2022-11-28 20:59:47 UTC (rev 65131)
@@ -16,8 +16,8 @@
\begin{document}
\begin{phiquation}
x -> [
- @ -> |foo|(5),
- y -> [ \lambda -> M_1 ]].
+ @ -> foo(5),
+ y -> [ L> M_1 ]].
\end{phiquation}
\end{document}
```
Modified: trunk/Master/texmf-dist/doc/latex/eolang/eolang.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/eolang/eolang.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/eolang/eolang.dtx 2022-11-28 16:12:15 UTC (rev 65130)
+++ trunk/Master/texmf-dist/source/latex/eolang/eolang.dtx 2022-11-28 20:59:47 UTC (rev 65131)
@@ -50,7 +50,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{eolang}
%<*package>
-[2022-11-18 0.7.0 Formulas and Graphs for EO Programming Language]
+[2022-11-28 0.7.1 Formulas and Graphs for EO Programming Language]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -196,8 +196,8 @@
% \begin{document}
% \begin{sodg}
% v0 \\ v0===> \\ v0!!A
-% v1 xy:v0,-.8,2.8 data:42 \\ =>v1
-% v0->v1 a:x rho
+% v1 xy:v0,-.8,2.8 data:42 tag:d_1
+% v0->v1 a:x rho \\ =>v1
% v2 xy:v0,+1,+1 atom:\xi.x+1
% v1->v2 a:|hi| bend:-15
% v2->v0 pi bend:10 % a comment
@@ -212,6 +212,7 @@
% The following markers are supported for a vertex:
% \begin{itemize}\setlength\itemsep{0em}
+% \item ``|tag:<math>|'' puts a custom label |<math>| into the circle,
% \item ``|data:[<box>]|'' makes it a data vertex with an optional attached ``|<box>|''
% (the content of the box may only be numeric data),
% \item ``|atom:[<box>]|'' makes it an atom with an optional attached ``|<box>|''
@@ -250,7 +251,7 @@
% \DescribeMacro{\phic}
% \DescribeMacro{\xmir}
% 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
+% \eolang{} language. It understands the |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. The macro |\xmir| prints "XMIR".
% \docshotOptions{firstline=4,lastline=10}
@@ -271,7 +272,7 @@
% \DescribeMacro{\phiWave}
% \DescribeMacro{\phiDotted}
% A few simple commands are defined to help you render arrows.
-% It is recommende not to use them directly, but use |!->| instead. However, if you
+% It is recommended not to use them directly, but use |!->| instead. However, if you
% want to use |\phiConst|, wrap it in |\mathrel| for better display:
% \docshotOptions{firstline=6,lastline=12}
% \begin{docshot}
@@ -281,17 +282,36 @@
% \usepackage{eolang}
% \begin{document}\noindent
% If $x$ is an identifier and $y$ is
-% an objects, then $x \phiConst y$
+% an object, then $x \phiConst y$
% makes $y$ a constant,
% $x \phiWave y$ makes it a decoratee
-% of arbitrary number of control-flow
-% objects, while $x \phiDotted y$
-% makes it a special attribute.
+% of an arbitrary number of objects,
+% while $x \phiDotted y$ makes it
+% a special attribute.
% \end{document}
% \end{docshot}
+% \DescribeMacro{\phiOset}
+% \DescribeMacro{\phiUset}
+% If you want to put a text over an arrow or under it, use |\phiOset| and |\phiUset| respectively:
+% \docshotOptions{firstline=6,lastline=11}
+% \begin{docshot}
+% \documentclass{article}
+% \pagestyle{empty}
+% \usepackage[paperwidth=3in]{geometry}
+% \usepackage{eolang}
+% \begin{document}\noindent
+% When the names of attributes and their
+% values don't matter, we use an arrow
+% with a star, for example:
+% \begin{phiquation*}
+% [[ \phiOset{*}{->} ]].
+% \end{phiquation*}
+% \end{document}
+% \end{docshot}
+
% \DescribeMacro{\phiMany}
-% Sometimes you may need to simplify the way you describe an object:
+% Sometimes you may need to simplify the way you describe an object (the typesetting is a bit off, but this is not because of us, but because of \href{https://tex.stackexchange.com/questions/664772}{this}):
% \docshotOptions{firstline=6,lastline=14}
% \begin{docshot}
% \documentclass{article}
@@ -311,10 +331,30 @@
% \end{document}
% \end{docshot}
+% \DescribeMacro{\phiSaveTo}
+% \DescribeMacro{\sodgSaveTo}
+% If you want to use |phiquation| or |sodg| environments inside |tabular| or any other environment or command, you won't be able to do this, because |phiquation| and |sodg| are ``verbatim'' environments. |\phiSaveTo| and |\sodgSaveTo| commands will help you in this situation. You use them right before |\begin{phiquation}| or |\begin{sodg}| respectively --- the content of the equation or the graph won't be rendered, but instead saved to the file. Later, inside |tabular|, you can use it through the |\input| macro (don't forget the |\parbox|):
+% \docshotOptions{firstline=5,lastline=12}
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage{eolang}
+% \pagestyle{empty}
+% \begin{document}
+% \phiSaveTo{a}
+% \begin{phiquation*}
+% [[ x -> [[D>42]] ]]
+% \end{phiquation*}
+% \begin{tabular}{p{.5in}l}
+% Free: & $[[x -> ?]]$ \\
+% Bound: & \parbox{1in}{\input{a}} \\
+% \end{tabular}
+% \end{document}
+% \end{docshot}
+
% \section{Package Options}
% \DescribeMacro{tmpdir}
-% The default location of temp files is |_eolang|. You can change this using |tmpdir| option:
+% The default location of temp files is |_eolang|. You can change this with the help of the |tmpdir| package option:
%\iffalse
%<*verb>
%\fi
@@ -326,7 +366,7 @@
%\fi
% \DescribeMacro{nodollar}
-% You may disable special treatment of the dollar sign:
+% You may disable the special treatment of the dollar sign by using the |nodollar| package option:
%\iffalse
%<*verb>
%\fi
@@ -359,7 +399,7 @@
% \end{document}
% \end{docshot}
-% This is how you can use |\dfrac| from |amsmath| for large inference rules,
+% This is how you can use |\dfrac| from \href{https://ctan.org/pkg/amsmath}{amsmath} for large inference rules,
% with the help of |\begin{split}| and |\end{split}|:
% \docshotOptions{firstline=6,lastline=15}
% \begin{docshot}
@@ -381,7 +421,7 @@
% \end{document}
% \end{docshot}
-% The |phiquation| environment may be used together with \href{https://ctan.org/pkg/acmart}{acmart}:
+% The |phiquation| environment may be used together with the \href{https://ctan.org/pkg/acmart}{acmart} package:
% \begin{docshot}
% \documentclass{acmart}
% \usepackage{eolang}
@@ -396,7 +436,7 @@
% \end{document}
% \end{docshot}
-% It's possible to use |\label| inside |phiquation| environment:
+% It's possible to use |\label| inside the |phiquation| environment (pay attention to how you can disable our custom parsing of math formulas by means of curled brackets around the ``|4|'' number):
% \docshotOptions{firstline=6,lastline=13}
% \begin{docshot}
% \documentclass{article}
@@ -407,7 +447,7 @@
% Discriminant can be calculated using
% the following simple formula:
% \begin{phiquation}
-% D = b{^2} - 4ac.
+% D = b{^2} - {4}ac.
% \label{d}
% \end{phiquation}
% Eq.~\ref{d} is also widely used in
@@ -415,6 +455,36 @@
% \end{document}
% \end{docshot}
+% You can add comments to your equations, using the |&&| command (pay attention, the text inside |\text{}| is not processed and treated like a plain text):
+% \docshotOptions{firstline=6,lastline=10}
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[paperwidth=4in]{geometry}
+% \usepackage{eolang}
+% \pagestyle{empty}
+% \begin{document}
+% \begin{phiquation*}
+% [[ 0->x ]] && \text{This is formation}
+% [[ 0->? ]] && \text{Abstraction}
+% x(D>42) && \text{Application}
+% \end{phiquation*}
+% \end{document}
+% \end{docshot}
+
+% If you don't use |nodollar| package option, you can still use normal parsing of the dollar sign, by means of |\(...\)| syntax:
+% \docshotOptions{firstline=6,lastline=8}
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[paperwidth=3in]{geometry}
+% \usepackage{eolang}
+% \pagestyle{empty}
+% \begin{document}\noindent
+% The object formation $[[0->x]]$
+% may be replaced with a formula
+% \( Q \times a^2 \).
+% \end{document}
+% \end{docshot}
+
% The |phiquation| environment will automatically align formulas by the first
% arrow, if there are only left-aligned formulas:
% \docshotOptions{firstline=5,lastline=10}
@@ -440,7 +510,7 @@
% \thispagestyle{empty}
% \begin{document}
% \begin{phiquation*}
-% [[ b -> ? ]], \\
+% [[ b -> ? ]],
% [[ @ -> TRUE, \Delta ..> 42 ]], \\
% \Delta = |43-09|.
% \end{phiquation*}
@@ -604,23 +674,24 @@
% \begin{macro}{eolang-phi.pl}
% \changes{0.0.2}{2022/10/21}{The symbols ``\texttt{[}'' and ``\texttt{]}'' replaced with ``\texttt{[[}'' and ``\texttt{]]}'' 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 ``\texttt{@},'' ``\texttt{\^{}},'' and ``\texttt{\&}'' enabled (\texttt{\char`\\varphi}, \texttt{\char`\\rho}, and \texttt{\char`\\sigma})}
+% \changes{0.0.2}{2022/10/21}{Parsing of the symbols ``\texttt{@},'' ``\texttt{\^{}},'' and ``\texttt{\&}'' enabled (\texttt{\char`\\varphi}, \texttt{\char`\\rho}, and \texttt{\char`\\sigma})}
% \changes{0.1.0}{2022/10/26}{A new Perl script "\texttt{eolang-phi.pl}" added for parsing of phi expressions.}
% \changes{0.2.0}{2022/10/29}{Numbers automatically render as \texttt{\char`\\texttt}. No need to use vertical bars around them anymore.}
% \changes{0.3.0}{2022/10/30}{New arrow added, that looks like \texttt{\char`\\leadsto}.}
% \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/13}{A new syntax introduced for the \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->}.}
% \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.}
+% \changes{0.8.0}{2022/11/21}{Inside \texttt{phiquation} any text inside the \texttt{\char`\\text} macro is not processed.}
% Then, we create a Perl script for |phiquation| processing using |VerbatimOut| environment from
% \href{https://ctan.org/pkg/fancyvrb}{fancyvrb}:
% \begin{macrocode}
\makeatletter
\begin{VerbatimOut}{\eolang at tmpdir/eolang-phi.pl}
-$env = $ARGV[0];
+$macro = $ARGV[0];
open(my $fh, '<', $ARGV[1]);
my $tex; { local $/; $tex = <$fh>; }
print '% This file is auto-generated', "\n";
@@ -639,34 +710,70 @@
$tex =~ s/%.*\n/\n/g;
$tex =~ s/^\s+|\s+$//g;
my $gathered = (0 == $tex =~ /\n\s+/g);
-if ($env ne 'phiq') {
- $tex =~ s/\s+\\\n\s*//g;
+if ($gathered) {
+ print '% The "gathered" is used since all lines are left-aligned' . "\n";
+}
+my $align = 0;
+print '% The "align" is NOT used by default' . "\n";
+if (index($tex, '&&') >= 0) {
+ $macro =~ s/equation/align/g;
+ $align = 1;
+ print '% The "align" is used because of && seen in the text' . "\n";
+}
+if ($macro ne 'phiq') {
$tex =~ s/\\\\\n/\n\n/g;
+ $tex =~ s/\\\n\s*//g;
$tex =~ s/\n*(\\label\{[^\}]+\})\n*/\1/g;
+ $tex =~ s/\n{3,}/\n\n/g;
}
-$tex =~ s/&/\\sigma{}/g;
+my @texts = ();
+sub trep {
+ my ($s) = @_;
+ my $open = 0;
+ my $p = 0;
+ for (; $p < length($s); $p++) {
+ $c = substr($s, $p, 1);
+ if ($c eq '}') {
+ if ($open eq 0) {
+ last;
+ }
+ $open--;
+ }
+ if ($c eq '{') {
+ $open++;
+ }
+ }
+ push(@texts, substr($s, 0, $p));
+ return '{TEXT' . (0+ at texts - 1) . '}' . substr($s, $p + 1);
+}
+$tex =~ s/\\text\{(.+)/trep("$1")/ge;
+$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/(^|(?<=[\s)(\]\[,.>\/]))([a-z][a-z0-9]+)(?=[\s)(\]\[,.-]|$)/|\2|/g;
$tex =~ s/([^^_]|^)([0-9]+|\*)\/(\\?[a-z]+|\|[a-z]+\|)
(->|\.\.>|~>|:=|!->)/\1\\alpha_{\2}\\vert{}\3\\space{}\4/xg;
$tex =~ s/([^^_]|^)([0-9]+|\*)
(->|\.\.>|~>|:=|!->)/\1\\alpha_{\2}\\space{}\3/xg;
-if ($env ne 'phiq') {
+if ($macro ne 'phiq') {
$tex =~ s/\\begin\{split\}\n/\\begin{split}&/g;
$tex =~ s/\n\s*\\end\{split\}/\\end{split}/g;
$tex =~ s/\n\n/\\\\&/g;
- $tex =~ s/\n/\\\\[-4pt]&/g;
+ $tex =~ s/\n/\\phiEOL{}\n&/g;
+ $tex =~ s/\\\\/\\\\\n/g;
$tex =~ s/([^&\s])\s{2}([^\s])/\1 \2/g;
$tex =~ s/\s{2}/ \\quad{}/g;
- my @leads = $tex =~ /&[^\s]+\s(->|:=|=)/g;
+ $tex = '&' . $tex;
+ my $lead = '[^\s]+\s(->|:=|=)';
+ my @leads = $tex =~ /&${lead}/g;
my @eols = $tex =~ /&/g;
- $tex = '&' . $tex;
if (0+ at leads == 0+ at eols && 0+ at eols > 0) {
- $tex =~ s/&([^\s\}]+)\s/\1&/g;
+ $tex =~ s/&${lead}/\1&/g;
$gathered = 0;
+ print '% The "gathered" is NOT used because all ' .
+ (0+ at eols) . ' lines are ' . (0+ at leads) . " leads\n";
}
}
$tex =~ s/\$/\\xi{}/g;
@@ -673,8 +780,8 @@
$tex =~ s/(?<!\{)\^/\\rho{}/g;
$tex =~ s/\[\[/\\llbracket\\mathrel{}/g;
$tex =~ s/\]\]/\\mathrel{}\\rrbracket{}/g;
-$tex =~ s/([\s,>\(])([0-9A-F]{2}(?:-[0-9A-F]{2})+|
- [0-9]+(?:\.[0-9]+)?)/\1|\2|/xg;
+$tex =~ s/([\s,>(])([0-9A-F]{2}(?:-[0-9A-F]{2})+|
+ [0-9]+(?:\.[0-9]+)?)(?!\{)/\1|\2|/xg;
$tex =~ s/TRUE/|TRUE|/g;
$tex =~ s/FALSE/|FALSE|/g;
$tex =~ s/\?/\\varnothing{}/g;
@@ -687,30 +794,37 @@
$tex =~ s/\.\.>/\\mathrel{\\phiDotted}/g;
$tex =~ s/\|{2,}/|/g;
$tex =~ s/\|([^\|]+)\|/\\textnormal{\\texttt{\1}}{}/g;
-if ($env eq 'phiq') {
+$tex =~ s/\{TEXT(\d+)\}/'\\text{' . @texts[$1] . '}';/ge;
+if ($macro eq 'phiq') {
print '$' if ($tex ne '');
} else {
- print '\begin{', $env, '}';
- if ($gathered) {
- print '\begin{gathered}';
- } else {
- print '\begin{split}';
+ print '\begin{', $macro, "}\n";
+ if (not($align)) {
+ if ($gathered) {
+ print '\begin{gathered}';
+ } else {
+ print '\begin{split}';
+ }
+ print "\n";
}
}
-if ($gathered) {
- $tex =~ s/(\\\\(?:\[[^\]]+\])?)&/\1/g;
+if ($gathered and not($align)) {
$tex =~ s/^&//g;
+ $tex =~ s/\n&/\n/g;
}
print $tex;
-if ($env eq 'phiq') {
+if ($macro eq 'phiq') {
print '$' if ($tex ne '');
} else {
- if ($gathered) {
- print '\end{gathered}';
- } else {
- print '\end{split}';
+ if (not($align)) {
+ print "\n";
+ if ($gathered) {
+ print '\end{gathered}';
+ } else {
+ print '\end{split}';
+ }
}
- print '\end{', $env, '}';
+ print "\n" . '\end{' . $macro . '}';
}
print '\endinput';
\end{VerbatimOut}
@@ -720,8 +834,18 @@
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\phiSaveTo}
+% \changes{0.8.0}{2022/11/20}{The output of the \texttt{phiquation} environment can be redirected to a file.}
+% Then, we define the |\phiSaveTo| command to instruct the |phiquation| environment that the output should not be sent to the document but saved to the file instead:
+% \begin{macrocode}
+\makeatletter
+\newcommand\phiSaveTo[1]{\def\eolang at phiSaveTo{#1}}
+\makeatother
+% \end{macrocode}
+% \end{macro}
+
% \begin{macro}{phiquation}
-% Then, we define |phiquation| and |phiquation*| environments through a supplementary
+% Then, we define the |phiquation| and the |phiquation*| environments through a supplementary
% |\eolang at process| command:
% \begin{macrocode}
\makeatletter\newcommand\eolang at process[1]{
@@ -733,8 +857,10 @@
perl "\eolang at tmpdir/eolang-phi.pl"
'#1'
"\eolang at tmpdir/\jobname/\hash.tex"
- \ifdefined\eolang at nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi}%
+ \ifdefined\eolang at nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi
+ \ifdefined\eolang at phiSaveTo > \eolang at phiSaveTo\fi}%
\setcounter{FancyVerbLine}{\value{eolang at lineno}}%
+ \def\eolang at phiSaveTo{\relax}%
}
\newenvironment{phiquation*}%
{\catcode`\|=12 \VerbatimEnvironment%
@@ -774,7 +900,7 @@
% \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}.}
+% \changes{0.7.0}{2022/11/18}{Now it is possible to use dollar sign instead of the \texttt{\char`\\phiq} command.}
% Then, we redefine dollar sign:
% \begin{macrocode}
\ifdefined\eolang at nodollar\else
@@ -790,15 +916,16 @@
% \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}.}
-% \changes{0.2.0}{2022/10/28}{The content of \texttt{atom} and \texttt{data} boxes is parsed automatically as formulas and numbers, respectively.}
-% \changes{0.4.0}{2022/10/31}{Labels on the edges are automatically printed as math formulas. Also, boxes are prefixed with \texttt{\char`\\Delta} and \texttt{\char`\\lambda} commands.}
+% \changes{0.2.0}{2022/10/28}{The content of the \texttt{atom} and the \texttt{data} boxes is parsed automatically as formulas and numbers, respectively.}
+% \changes{0.4.0}{2022/10/31}{Labels on the edges are automatically printed as math formulas. Also, boxes are prefixed with the \texttt{\char`\\Delta} and the \texttt{\char`\\lambda} commands.}
% \changes{0.4.0}{2022/10/31}{Relative positioning of vertices fixed.}
-% \changes{0.4.0}{2022/10/31}{Transforming arrows added with \texttt{=>} syntax, also markers with exclamation mark syntax.}
+% \changes{0.4.0}{2022/10/31}{Transforming arrows added with the \texttt{=>} syntax, also markers with exclamation mark syntax.}
% \changes{0.5.0}{2022/11/09}{New syntax introduced that allows to make clones of vertices and all their dependants.}
-% \changes{0.5.0}{2022/11/09}{Now edges may have \texttt{break} attribute, to make them shorter.}
-% \changes{0.5.0}{2022/11/10}{It is possible to use multiple ``equaltion sign'' symbols for transition arrows \texttt{=>}.}
-% \changes{0.5.0}{2022/11/12}{It is possible to use tikz commands inside \texttt{sodg} environment.}
-% \changes{0.6.0}{2022/11/13}{The attribute \texttt{rrho} is retired, now \texttt{rho} works just fine in all situations.}
+% \changes{0.5.0}{2022/11/09}{Now edges may have the \texttt{break} attribute, to make them shorter.}
+% \changes{0.5.0}{2022/11/10}{It is possible to use multiple the ``equaltion sign'' symbols for transition arrows \texttt{=>}.}
+% \changes{0.5.0}{2022/11/12}{It is possible to use TikZ commands inside the \texttt{sodg} environment.}
+% \changes{0.6.0}{2022/11/13}{The \texttt{rrho} attribute is retired, now \texttt{rho} works just fine in all situations.}
+% \changes{0.8.0}{2022/11/20}{The \texttt{tag} attribute is introduced for changing labels inside a vertex circle.}
% Then, we create a Perl script for |sodg| graphs processing using |VerbatimOut| from
% \href{https://ctan.org/pkg/fancyvrb}{fancyvrb}:
% \begin{macrocode}
@@ -1037,8 +1164,20 @@
print ',phi-object';
}
print ']';
- print ' (', $head, ')';
- print ' {$' . vertex($head) . '$}';
+ print ' (' . $head . ')';
+ print ' {';
+ if (exists $opts{'tag'}) {
+ my $t = $opts{'tag'};
+ if (index($t, '$') == -1) {
+ $t = '$' . $t . '$';
+ } else {
+ $t = fmt($t);
+ }
+ print $t;
+ } else {
+ print '$' . vertex($head) . '$';
+ }
+ print '}';
if (exists $opts{'box'}) {
print ' node[phi-box] at (';
print $head, '.south east) {';
@@ -1077,7 +1216,6 @@
\RequirePackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
- \usetikzlibrary{snakes}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}
@@ -1173,6 +1311,16 @@
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\sodgSaveTo}
+% \changes{0.8.0}{2022/11/20}{The output of the \texttt{sodg} environment can be redirected to a file.}
+% Then, we define the |\sodgSaveTo| command to instruct the |sodg| environment that the output should not be sent to the document but saved to the file instead:
+% \begin{macrocode}
+\makeatletter
+\newcommand\sodgSaveTo[1]{\def\eolang at sodgSaveTo{#1}}
+\makeatother
+% \end{macrocode}
+% \end{macro}
+
% \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, we create a new environment |sodg|, as suggested
@@ -1192,9 +1340,11 @@
\iexec[trace,stdout=\eolang at tmpdir/\jobname/\hash-post.tex]{
perl "\eolang at tmpdir/eolang-sodg.pl"
"\eolang at tmpdir/\jobname/\hash.tex"
- \ifdefined\eolang at nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi}%
+ \ifdefined\eolang at nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi
+ \ifdefined\eolang at sodgSaveTo > \eolang at sodgSaveTo\fi}%
\catcode`\$\active%
\setcounter{FancyVerbLine}{\value{eolang at lineno}}%
+ \def\eolang at sodgSaveTo{\relax}%
}\makeatother
% \end{macrocode}
% \end{macro}
@@ -1202,7 +1352,7 @@
% \begin{macro}{\eolang}
% Then, we define a simple supplementary command to help you print \eolang{}, the name of our language.
% \changes{0.1.0}{2022/10/25}{New command \texttt{\char`\\eolang} added to print the name of the language in both
-% normal and anonymous mode of \texttt{acmart}.}
+% normal and the anonymous mode of \texttt{acmart}.}
% \begin{macrocode}
\newcommand\eolang{%
\ifdefined\anon%
@@ -1217,15 +1367,15 @@
% \begin{macro}{\phic}
% Then, we define a simple supplementary command to help you print \phic{}, the name of our formal apparatus.
% \changes{0.1.0}{2022/10/25}{New command \texttt{\char`\\phic} prints the name of $\varphi$-calculus in both
-% normal and anonymous mode of \texttt{acmart}.}
+% normal and the anonymous mode of \texttt{acmart}.}
% \begin{macrocode}
\RequirePackage{hyperref}
\newcommand\phic{%
\ifdefined\anon%
- \anon[\texorpdfstring{$\alpha$}{a}-calculus]
- {\texorpdfstring{$\varphi$}{phi}-calculus}%
+ \anon[\texorpdfstring{$\alpha$}{a}-cal\-cu\-lus]
+ {\texorpdfstring{$\varphi$}{phi}-cal\-cu\-lus}%
\else%
- \texorpdfstring{$\varphi$}{phi}-calculus%
+ \texorpdfstring{$\varphi$}{phi}-cal\-cu\-lus%
\fi%
}
% \end{macrocode}
@@ -1233,7 +1383,7 @@
% \begin{macro}{\xmir}
% Then, we define a simple supplementary command to help you print \xmir{}, the name of our XML-based format of program representation.
-% \changes{0.2.0}{2022/10/28}{New command \texttt{\char`\\xmir} prints XMIR in both normal and anonymous mode of \texttt{acmart}.}
+% \changes{0.2.0}{2022/10/28}{New command \texttt{\char`\\xmir} prints XMIR in both normal and the anonymous mode of \texttt{acmart}.}
% \begin{macrocode}
\newcommand\xmir{%
\ifdefined\anon%
@@ -1275,15 +1425,40 @@
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\phiOset}
+% \changes{0.8.0}{2022/11/20}{New commands \texttt{\char`\\phiOset} and \texttt{\char`\\phiUset} help position text over and under an arrow.}
+% Then, we define two commands to position a text over and under an arrow, as suggested \href{https://tex.stackexchange.com/a/194805/1449}{here}:
+% \begin{macrocode}
+\makeatletter
+\newcommand{\phiOset}[2]{%
+ \mathrel{\mathop{#2}\limits^{
+ \vbox to 0ex{\kern-2\ex@
+ \hbox{$\scriptscriptstyle#1$}\vss}}}}
+\newcommand{\phiUset}[2]{%
+ \mathrel{\mathop{#2}\limits_{
+ \vbox to 0ex{\kern-6.3\ex@
+ \hbox{$\scriptscriptstyle#1$}\vss}}}}
+\makeatother
+% \end{macrocode}
+% \end{macro}
+
% \begin{macro}{\phiMany}
% \changes{0.5.0}{2022/11/10}{New command \texttt{\char`\\phiMany} enables iterating over an arrow.}
-% Then, we define a command to an arrow with iterating indecies:
+% Then, we define a command for an arrow with iterating indecies:
% \begin{macrocode}
\newcommand\phiMany[3]{%
- \overunderset{\scriptscriptstyle #3}{\scriptscriptstyle #2}{#1}}
+ \phiOset{#3}{\phiUset{#2}{#1}}}
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\phiEOL}
+% \changes{0.9.0}{2022/11/24}{New command \texttt{\char`\\phiEOL} added, instead of \texttt{\char`\\\char`\\[-4pt]}.}
+% Then, we define a command for line breaks in formulas:
+% \begin{macrocode}
+\newcommand\phiEOL{\\[-4pt]}
+% \end{macrocode}
+% \end{macro}
+
% \begin{macro}{\phiDotted}
% \changes{0.1.0}{2022/10/27}{New command \texttt{\char`\\phiDotted} added to denote a link to a special attribute.}
% Then, we define a command to render an arrow for a special attribute,
Modified: trunk/Master/texmf-dist/tex/latex/eolang/eolang.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/eolang/eolang.sty 2022-11-28 16:12:15 UTC (rev 65130)
+++ trunk/Master/texmf-dist/tex/latex/eolang/eolang.sty 2022-11-28 20:59:47 UTC (rev 65131)
@@ -31,7 +31,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{eolang}
-[2022-11-18 0.7.0 Formulas and Graphs for EO Programming Language]
+[2022-11-28 0.7.1 Formulas and Graphs for EO Programming Language]
@@ -69,6 +69,10 @@
+
+
+
+
\RequirePackage{stmaryrd}
\RequirePackage{amsmath}
\let\Bbbk\relax\RequirePackage{amssymb}
@@ -98,7 +102,7 @@
\makeatletter
\begin{VerbatimOut}{\eolang at tmpdir/eolang-phi.pl}
-$env = $ARGV[0];
+$macro = $ARGV[0];
open(my $fh, '<', $ARGV[1]);
my $tex; { local $/; $tex = <$fh>; }
print '% This file is auto-generated', "\n";
@@ -117,34 +121,70 @@
$tex =~ s/%.*\n/\n/g;
$tex =~ s/^\s+|\s+$//g;
my $gathered = (0 == $tex =~ /\n\s+/g);
-if ($env ne 'phiq') {
- $tex =~ s/\s+\\\n\s*//g;
+if ($gathered) {
+print '% The "gathered" is used since all lines are left-aligned' . "\n";
+}
+my $align = 0;
+print '% The "align" is NOT used by default' . "\n";
+if (index($tex, '&&') >= 0) {
+ $macro =~ s/equation/align/g;
+ $align = 1;
+ print '% The "align" is used because of && seen in the text' . "\n";
+}
+if ($macro ne 'phiq') {
$tex =~ s/\\\\\n/\n\n/g;
+ $tex =~ s/\\\n\s*//g;
$tex =~ s/\n*(\\label\{[^\}]+\})\n*/\1/g;
+ $tex =~ s/\n{3,}/\n\n/g;
}
-$tex =~ s/&/\\sigma{}/g;
+my @texts = ();
+sub trep {
+ my ($s) = @_;
+ my $open = 0;
+ my $p = 0;
+ for (; $p < length($s); $p++) {
+ $c = substr($s, $p, 1);
+ if ($c eq '}') {
+ if ($open eq 0) {
+ last;
+ }
+ $open--;
+ }
+ if ($c eq '{') {
+ $open++;
+ }
+}
+ push(@texts, substr($s, 0, $p));
+ return '{TEXT' . (0+ at texts - 1) . '}' . substr($s, $p + 1);
+}
+$tex =~ s/\\text\{(.+)/trep("$1")/ge;
+$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/(^|(?<=[\s)(\]\[,.>\/]))([a-z][a-z0-9]+)(?=[\s)(\]\[,.-]|$)/|\2|/g;
$tex =~ s/([^^_]|^)([0-9]+|\*)\/(\\?[a-z]+|\|[a-z]+\|)
(->|\.\.>|~>|:=|!->)/\1\\alpha_{\2}\\vert{}\3\\space{}\4/xg;
$tex =~ s/([^^_]|^)([0-9]+|\*)
(->|\.\.>|~>|:=|!->)/\1\\alpha_{\2}\\space{}\3/xg;
-if ($env ne 'phiq') {
+if ($macro ne 'phiq') {
$tex =~ s/\\begin\{split\}\n/\\begin{split}&/g;
$tex =~ s/\n\s*\\end\{split\}/\\end{split}/g;
$tex =~ s/\n\n/\\\\&/g;
- $tex =~ s/\n/\\\\[-4pt]&/g;
+ $tex =~ s/\n/\\phiEOL{}\n&/g;
+ $tex =~ s/\\\\/\\\\\n/g;
$tex =~ s/([^&\s])\s{2}([^\s])/\1 \2/g;
$tex =~ s/\s{2}/ \\quad{}/g;
- my @leads = $tex =~ /&[^\s]+\s(->|:=|=)/g;
+ $tex = '&' . $tex;
+ my $lead = '[^\s]+\s(->|:=|=)';
+ my @leads = $tex =~ /&${lead}/g;
my @eols = $tex =~ /&/g;
- $tex = '&' . $tex;
if (0+ at leads == 0+ at eols && 0+ at eols > 0) {
- $tex =~ s/&([^\s\}]+)\s/\1&/g;
+ $tex =~ s/&${lead}/\1&/g;
$gathered = 0;
+ print '% The "gathered" is NOT used because all ' .
+ (0+ at eols) . ' lines are ' . (0+ at leads) . " leads\n";
}
}
$tex =~ s/\$/\\xi{}/g;
@@ -151,8 +191,8 @@
$tex =~ s/(?<!\{)\^/\\rho{}/g;
$tex =~ s/\[\[/\\llbracket\\mathrel{}/g;
$tex =~ s/\]\]/\\mathrel{}\\rrbracket{}/g;
-$tex =~ s/([\s,>\(])([0-9A-F]{2}(?:-[0-9A-F]{2})+|
- [0-9]+(?:\.[0-9]+)?)/\1|\2|/xg;
+$tex =~ s/([\s,>(])([0-9A-F]{2}(?:-[0-9A-F]{2})+|
+ [0-9]+(?:\.[0-9]+)?)(?!\{)/\1|\2|/xg;
$tex =~ s/TRUE/|TRUE|/g;
$tex =~ s/FALSE/|FALSE|/g;
$tex =~ s/\?/\\varnothing{}/g;
@@ -165,30 +205,37 @@
$tex =~ s/\.\.>/\\mathrel{\\phiDotted}/g;
$tex =~ s/\|{2,}/|/g;
$tex =~ s/\|([^\|]+)\|/\\textnormal{\\texttt{\1}}{}/g;
-if ($env eq 'phiq') {
+$tex =~ s/\{TEXT(\d+)\}/'\\text{' . @texts[$1] . '}';/ge;
+if ($macro eq 'phiq') {
print '$' if ($tex ne '');
} else {
- print '\begin{', $env, '}';
+ print '\begin{', $macro, "}\n";
+ if (not($align)) {
if ($gathered) {
print '\begin{gathered}';
} else {
print '\begin{split}';
}
+ print "\n";
+ }
}
-if ($gathered) {
- $tex =~ s/(\\\\(?:\[[^\]]+\])?)&/\1/g;
+if ($gathered and not($align)) {
$tex =~ s/^&//g;
+ $tex =~ s/\n&/\n/g;
}
print $tex;
-if ($env eq 'phiq') {
+if ($macro eq 'phiq') {
print '$' if ($tex ne '');
} else {
+ if (not($align)) {
+ print "\n";
if ($gathered) {
print '\end{gathered}';
} else {
print '\end{split}';
}
- print '\end{', $env, '}';
+ }
+ print "\n" . '\end{' . $macro . '}';
}
print '\endinput';
\end{VerbatimOut}
@@ -196,6 +243,10 @@
'\eolang at tmpdir/eolang-phi.pl' saved^^J}%
\makeatother
+\makeatletter
+\newcommand\phiSaveTo[1]{\def\eolang at phiSaveTo{#1}}
+\makeatother
+
\makeatletter\newcommand\eolang at process[1]{
\def\hash{\eolang at mdfive
{\eolang at tmpdir/\jobname/phiquation.tex}}%
@@ -205,8 +256,10 @@
perl "\eolang at tmpdir/eolang-phi.pl"
'#1'
"\eolang at tmpdir/\jobname/\hash.tex"
- \ifdefined\eolang at nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi}%
+ \ifdefined\eolang at nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi
+ \ifdefined\eolang at phiSaveTo > \eolang at phiSaveTo\fi}%
\setcounter{FancyVerbLine}{\value{eolang at lineno}}%
+ \def\eolang at phiSaveTo{\relax}%
}
\newenvironment{phiquation*}%
{\catcode`\|=12 \VerbatimEnvironment%
@@ -480,8 +533,20 @@
print ',phi-object';
}
print ']';
- print ' (', $head, ')';
- print ' {$' . vertex($head) . '$}';
+ print ' (' . $head . ')';
+ print ' {';
+ if (exists $opts{'tag'}) {
+ my $t = $opts{'tag'};
+ if (index($t, '$') == -1) {
+ $t = '$' . $t . '$';
+ } else {
+ $t = fmt($t);
+ }
+ print $t;
+ } else {
+ print '$' . vertex($head) . '$';
+ }
+ print '}';
if (exists $opts{'box'}) {
print ' node[phi-box] at (';
print $head, '.south east) {';
@@ -509,7 +574,6 @@
\RequirePackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
- \usetikzlibrary{snakes}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}
@@ -598,6 +662,10 @@
above=2pt,sloped/.append style={transform shape},
font={\scriptsize},color=black]
+\makeatletter
+\newcommand\sodgSaveTo[1]{\def\eolang at sodgSaveTo{#1}}
+\makeatother
+
\makeatletter\newenvironment{sodg}%
{\catcode`\|=12 \VerbatimEnvironment%
\setcounter{eolang at lineno}{\value{FancyVerbLine}}%
@@ -612,9 +680,11 @@
\iexec[trace,stdout=\eolang at tmpdir/\jobname/\hash-post.tex]{
perl "\eolang at tmpdir/eolang-sodg.pl"
"\eolang at tmpdir/\jobname/\hash.tex"
- \ifdefined\eolang at nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi}%
+ \ifdefined\eolang at nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi
+ \ifdefined\eolang at sodgSaveTo > \eolang at sodgSaveTo\fi}%
\catcode`\$\active%
\setcounter{FancyVerbLine}{\value{eolang at lineno}}%
+ \def\eolang at sodgSaveTo{\relax}%
}\makeatother
\newcommand\eolang{%
@@ -628,10 +698,10 @@
\RequirePackage{hyperref}
\newcommand\phic{%
\ifdefined\anon%
- \anon[\texorpdfstring{$\alpha$}{a}-calculus]
- {\texorpdfstring{$\varphi$}{phi}-calculus}%
+ \anon[\texorpdfstring{$\alpha$}{a}-cal\-cu\-lus]
+ {\texorpdfstring{$\varphi$}{phi}-cal\-cu\-lus}%
\else%
- \texorpdfstring{$\varphi$}{phi}-calculus%
+ \texorpdfstring{$\varphi$}{phi}-cal\-cu\-lus%
\fi%
}
@@ -653,9 +723,22 @@
\newcommand\phiSlot[1]{%
\xrightarrow{\text{\sffamily\scshape #1}}}
+\makeatletter
+\newcommand{\phiOset}[2]{%
+ \mathrel{\mathop{#2}\limits^{
+ \vbox to 0ex{\kern-2\ex@
+ \hbox{$\scriptscriptstyle#1$}\vss}}}}
+\newcommand{\phiUset}[2]{%
+ \mathrel{\mathop{#2}\limits_{
+ \vbox to 0ex{\kern-6.3\ex@
+ \hbox{$\scriptscriptstyle#1$}\vss}}}}
+\makeatother
+
\newcommand\phiMany[3]{%
- \overunderset{\scriptscriptstyle #3}{\scriptscriptstyle #2}{#1}}
+ \phiOset{#3}{\phiUset{#2}{#1}}}
+\newcommand\phiEOL{\\[-4pt]}
+
\RequirePackage{trimclip}
\RequirePackage{amsfonts}
\makeatletter
More information about the tex-live-commits
mailing list.