diff options
author | Karl Berry <karl@freefriends.org> | 2012-12-20 00:31:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-12-20 00:31:22 +0000 |
commit | 4a0af717b48598c71c7c19e9dc189c20db4dc311 (patch) | |
tree | c24c5734816d484f6c2cb3fe65c8ed90b8717554 /Master/texmf-dist/tex | |
parent | 71441df00e80ebb3470475a2317e5b324011624b (diff) |
context-algorithmic (19dec12)
git-svn-id: svn://tug.org/texlive/trunk@28580 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.mkii (renamed from Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.tex) | 110 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.mkiv | 312 |
2 files changed, 387 insertions, 35 deletions
diff --git a/Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.tex b/Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.mkii index 91d23fa4dbe..95cd7a26401 100644 --- a/Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.tex +++ b/Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.mkii @@ -1,19 +1,37 @@ %D \module -%D [ file=t-algorithmic, -%D version=2009.04.21, -%D title=\CONTEXT\ User Module, -%D subtitle=Algorithms, -%D author=Wolfgang Schuster, -%D date=\currentdate, -%D copyright=Wolfgang Schuster, -%D email=schuster.wolfgang@googlemail.com, -%D license=Public Domain] +%D [ file=t-algorithmic, +%D version=2012.06.22, +%D title=\CONTEXT\ User Module, +%D subtitle=Algorithms, +%D author=Wolfgang Schuster, +%D date=\currentdate, +%D copyright=Wolfgang Schuster, +%D email=schuster.wolfgang@googlemail.com, +%D license=GNU General Public License] + +%C Copyright (C) 2010 Wolfgang Schuster +%C +%C This program is free software: you can redistribute it and/or modify +%C it under the terms of the GNU General Public License as published by +%C the Free Software Foundation, either version 3 of the License, or +%C any later version. +%C +%C This program is distributed in the hope that it will be useful, +%C but WITHOUT ANY WARRANTY; without even the implied warranty of +%C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%C GNU General Public License for more details. +%C +%C You should have received a copy of the GNU General Public License +%C along with this program. If not, see <http://www.gnu.org/licenses/>. \writestatus{loading}{Context User Module / Algorithms} \unprotect -\def\????al{@@@@al} % ALgorithmic +\def\????algorithmic{@@@@algorithmic} + +\def\algorithmicparameter#1% + {\csname\ifcsname\????algorithmic#1\endcsname\????algorithmic#1\else\s!empty\fi\endcsname} \def\startalgorithmic {\bgroup @@ -23,39 +41,37 @@ {\iffirstargument \setupalgorithmic[#1]% \fi - \def\algorithmiccommands##1% - {\uppercase{\expandafter\let\csname##1\expandafter\endcsname}\csname algorithmic!##1\endcsname}% - \processcommacommand[\algorithmic!list!commands]\algorithmiccommands - \@@@@albefore + \the\everyalgorithmic + \doifsomething{\algorithmicparameter\c!spacebefore}{\blank[\algorithmicparameter\c!spacebefore]}% + \algorithmicparameter\c!before \setupwhitespace[\v!none]% - \doadaptleftskip\@@@@almargin - \doif\@@@@alnumbering\v!line + \doadaptleftskip{\algorithmicparameter\c!margin}% + \doif{\algorithmicparameter\c!numbering}\v!yes {\setuplinenumbering - [\c!start=\@@@@alstart, - \c!stop=\@@@@alstop, - \c!step=\@@@@alstep]% + [\c!start=\algorithmicparameter\c!start, + \c!stop=\algorithmicparameter\c!stop, + \c!step=\algorithmicparameter\c!step]% \startlinenumbering}} \def\stopalgorithmic {\par - \doif\@@@@alnumbering\v!line\stoplinenumbering - \@@@@alafter + \doif{\algorithmicparameter\c!numbering}\v!yes\stoplinenumbering + \algorithmicparameter\c!after + \doifsomething{\algorithmicparameter\c!spaceafter}{\blank[\algorithmicparameter\c!spaceafter]}% \egroup} \def\setupalgorithmic - {\dodoubleargument\getparameters[\????al]} + {\dodoubleargument\getparameters[\????algorithmic]} % Commands -\def\algorithmic!list!commands - {state,if,else,elsif,endif,for,forall,endfor,while,endwhile,repeat,% - until,loop,endloop,require,ensure,return,true,false,print,comment} +\newtoks\everyalgorithmic \def\startsubalgorithmic - {\par\doadaptleftskip\@@@@alwidth} + {\par\doadaptleftskip{\algorithmicparameter\c!width}} \def\stopsubalgorithmic - {\par\doadaptleftskip{-\@@@@alwidth}} + {\par\doadaptleftskip{-\algorithmicparameter\c!width}} \def\algorithmic!state {\par} \def\algorithmic!if #1{\par\algorithmicif\ #1 \algorithmicthen\startsubalgorithmic} @@ -79,6 +95,30 @@ \def\algorithmic!print {\par\algorithmicprint\space} \def\algorithmic!comment {\algorithmiccomment} +\appendtoks + \let\STATE \algorithmic!state + \let\IF \algorithmic!if + \let\ELSE \algorithmic!else + \let\ELSIF \algorithmic!elsif + \let\ENDIF \algorithmic!endif + \let\FOR \algorithmic!for + \let\FORALL \algorithmic!forall + \let\ENDFOR \algorithmic!endfor + \let\WHILE \algorithmic!while + \let\ENDWHILE\algorithmic!endwhile + \let\REPEAT \algorithmic!repeat + \let\UNTIL \algorithmic!until + \let\LOOP \algorithmic!loop + \let\ENDLOOP \algorithmic!endloop + \let\REQUIRE \algorithmic!require + \let\ENSURE \algorithmic!ensure + \let\RETURN \algorithmic!return + \let\TRUE \algorithmic!true + \let\FALSE \algorithmic!false + \let\PRINT \algorithmic!print + \let\COMMENT \algorithmic!comment +\to \everyalgorithmic + % I should make this multilingual \def\algorithmicrequire {{\bf Require:}} @@ -108,13 +148,13 @@ % Default values \setupalgorithmic - [\c!numbering=\v!no, - \c!start=1, - \c!stop=, - \c!step=1, - \c!width=1em, - \c!margin=1em, - \c!before=\blank, - \c!after=\blank] + [ \c!numbering=\v!no, + \c!start=1, + \c!stop=, + \c!step=1, + \c!width=1em, + \c!margin=1em, + \c!spacebefore=\v!line, + \c!spaceafter=\v!line] \protect \endinput diff --git a/Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.mkiv b/Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.mkiv new file mode 100644 index 00000000000..6a985e5ac4e --- /dev/null +++ b/Master/texmf-dist/tex/context/third/algorithmic/t-algorithmic.mkiv @@ -0,0 +1,312 @@ +%D \module +%D [ file=t-algorithmic, +%D version=2012.12.18, +%D title=\CONTEXT\ User Module, +%D subtitle=Algorithms, +%D author=Wolfgang Schuster, +%D date=\currentdate, +%D copyright=Wolfgang Schuster, +%D email=schuster.wolfgang@googlemail.com, +%D license=GNU General Public License] + +%C Copyright (C) 2010 Wolfgang Schuster +%C +%C This program is free software: you can redistribute it and/or modify +%C it under the terms of the GNU General Public License as published by +%C the Free Software Foundation, either version 3 of the License, or +%C any later version. +%C +%C This program is distributed in the hope that it will be useful, +%C but WITHOUT ANY WARRANTY; without even the implied warranty of +%C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%C GNU General Public License for more details. +%C +%C You should have received a copy of the GNU General Public License +%C along with this program. If not, see <http://www.gnu.org/licenses/>. + +% begin info +% +% title : algorithmic +% comment : context port of the algorithmic package for latex +% status : final +% +% end info + +\writestatus{loading}{Context User Module / Algorithms} + +\unprotect + +\startinterface all + \setinterfaceconstant {labelstyle} {labelstyle} + \setinterfaceconstant {labelcolor} {labelcolor} +\stopinterface + +\startinterface all + \setinterfacevariable {algorithmic} {algorithmic} +\stopinterface + +\installnamespace {algorithmic} +\installcommandhandler \????algorithmic {algorithmic} \????algorithmic + +\appendtoks + \setuevalue{\e!start\currentalgorithmic}{\algorithmic_start[\currentalgorithmic]}% + \setuevalue{\e!stop \currentalgorithmic}{\algorithmic_stop }% +\to \everydefinealgorithmic + +\appendtoks + \definelinenumbering[\currentalgorithmic]% +\to \everydefinealgorithmic + +\appendtoks + \setuplinenumbering + [\currentalgorithmic] + [\c!conversion=\algorithmicparameter\c!conversion, + \c!start=\algorithmicparameter\c!start, + \c!step=\algorithmicparameter\c!step, + \c!method=\algorithmicparameter\c!method, + \c!continue=\algorithmicparameter\c!continue, + \c!location=\algorithmicparameter\c!location, + \c!style=\algorithmicparameter\c!numberstyle, + \c!color=\algorithmicparameter\c!numbercolor, + \c!width=\algorithmicparameter\c!numberwidth, + \c!align=\algorithmicparameter\c!align]% +\to \everysetupalgorithmic + +\unexpanded\def\algorithmic_start[#1]% + {\begingroup + \edef\currentalgorithmic{#1}% + \dosingleempty\algorithmic_start_indeed} + +\def\algorithmic_start_indeed[#1]% + {\iffirstargument + \setupcurrentalgorithmic[#1]% + \fi + \the\t_algorithmic_commands + \usealgorithmicstyleandcolor\c!style\c!color + \doifsomething{\algorithmicparameter\c!spacebefore}{\blank[\algorithmicparameter\c!spacebefore]}% + \algorithmicparameter\c!before + \setupwhitespace[\v!none]% + \doadaptleftskip{\algorithmicparameter\c!margin}% + \doif{\algorithmicparameter\c!numbering}\v!yes\startlinenumbering} + +\unexpanded\def\algorithmic_stop + {\par + \doif{\algorithmicparameter\c!numbering}\v!yes\stoplinenumbering + \algorithmicparameter\c!after + \doifsomething{\algorithmicparameter\c!spaceafter}{\blank[\algorithmicparameter\c!spaceafter]}% + \endgroup} + +% Commands + +\def\algorithmic_begsub + {\par\doadaptleftskip{\algorithmicparameter\c!width}} + +\def\algorithmic_endsub + {\par\doadaptleftskip{-\algorithmicparameter\c!width}} + +\def\algorithmic_label#1% + {\begingroup + \usealgorithmicstyleandcolor\c!labelstyle\c!labelcolor + \algorithmictext{#1}% + \endgroup} + +\starttexdefinition algorithmic_state + \par +\stoptexdefinition + +\starttexdefinition algorithmic_if #1 + \par + \algorithmic_label{if} #1 \algorithmic_label{then} + \algorithmic_begsub +\stoptexdefinition + +\starttexdefinition algorithmic_else + \algorithmic_endsub + \algorithmic_label{else} + \algorithmic_begsub +\stoptexdefinition + +\starttexdefinition algorithmic_elsif #1 + \algorithmic_endsub + \algorithmic_label{elsif} #1 \algorithmic_label{then} + \algorithmic_begsub +\stoptexdefinition + +\starttexdefinition algorithmic_endif + \algorithmic_endsub + \algorithmic_label{endif} +\stoptexdefinition + +\starttexdefinition algorithmic_for #1 + \par + \algorithmic_label{for} #1 \algorithmic_label{do} + \algorithmic_begsub +\stoptexdefinition + +\starttexdefinition algorithmic_forall #1 + \par + \algorithmic_label{forall} #1 \algorithmic_label{do} + \algorithmic_begsub +\stoptexdefinition + +\starttexdefinition algorithmic_endfor + \algorithmic_endsub + \algorithmic_label{endfor} +\stoptexdefinition + +\starttexdefinition algorithmic_while #1 + \par + \algorithmic_label{while} #1 \algorithmic_label{do} + \algorithmic_begsub +\stoptexdefinition + +\starttexdefinition algorithmic_endwhile + \algorithmic_endsub + \algorithmic_label{endwhile} +\stoptexdefinition + +\starttexdefinition algorithmic_repeat + \par + \algorithmic_label{repeat} + \algorithmic_begsub +\stoptexdefinition + +\starttexdefinition algorithmic_until #1 + \algorithmic_endsub + \algorithmic_label{until} #1 +\stoptexdefinition + +\starttexdefinition algorithmic_loop + \par + \algorithmic_label{loop} + \algorithmic_begsub +\stoptexdefinition + +\starttexdefinition algorithmic_endloop + \algorithmic_endsub + \algorithmic_label{endloop} +\stoptexdefinition + +\starttexdefinition algorithmic_require + \par + \algorithmic_label{require} + \space +\stoptexdefinition + +\starttexdefinition algorithmic_ensure + \par + \algorithmic_label{ensure} + \space +\stoptexdefinition + +\starttexdefinition algorithmic_return + \par + \algorithmic_label{return} + \space +\stoptexdefinition + +\starttexdefinition algorithmic_true + \algorithmic_label{true} +\stoptexdefinition + +\starttexdefinition algorithmic_false + \algorithmic_label{false} +\stoptexdefinition + +\starttexdefinition algorithmic_print + \par + \algorithmic_label{print} + \space +\stoptexdefinition + +\starttexdefinition algorithmic_comment #1 + \textbraceleft + #1 + \textbraceright +\stoptexdefinition + +% The commands in the environment are all uppercase, the connection +% between them and their defintion happens here. + +\newtoks\t_algorithmic_commands + +\def\algorithmic_define + {\dodoubleargument\algorithmic_define_indeed} + +\def\algorithmic_define_indeed[#1][#2]% + {\appendtoks\letvalue{#1}#2\to\t_algorithmic_commands} + +\algorithmic_define [STATE] [\algorithmic_state ] +\algorithmic_define [IF] [\algorithmic_if ] +\algorithmic_define [ELSE] [\algorithmic_else ] +\algorithmic_define [ELSIF] [\algorithmic_elsif ] +\algorithmic_define [ENDIF] [\algorithmic_endif ] +\algorithmic_define [FOR] [\algorithmic_for ] +\algorithmic_define [FORALL] [\algorithmic_forall ] +\algorithmic_define [ENDFOR] [\algorithmic_endfor ] +\algorithmic_define [WHILE] [\algorithmic_while ] +\algorithmic_define [ENDWHILE] [\algorithmic_endwhile] +\algorithmic_define [REPEAT] [\algorithmic_repeat ] +\algorithmic_define [UNTIL] [\algorithmic_until ] +\algorithmic_define [LOOP] [\algorithmic_loop ] +\algorithmic_define [ENDLOOP] [\algorithmic_endloop ] +\algorithmic_define [REQUIRE] [\algorithmic_require ] +\algorithmic_define [ENSURE] [\algorithmic_ensure ] +\algorithmic_define [RETURN] [\algorithmic_return ] +\algorithmic_define [TRUE] [\algorithmic_true ] +\algorithmic_define [FALSE] [\algorithmic_false ] +\algorithmic_define [PRINT] [\algorithmic_print ] +\algorithmic_define [COMMENT] [\algorithmic_comment ] + +% Labels + +\definelabelclass[algorithmic] + +\setupalgorithmictext[\s!en][require=Require:] +\setupalgorithmictext[\s!en][ensure=Ensure:] +\setupalgorithmictext[\s!en][end=end] +\setupalgorithmictext[\s!en][if=if] +\setupalgorithmictext[\s!en][then=then] +\setupalgorithmictext[\s!en][else=else] +\setupalgorithmictext[\s!en][elsif=else if] +\setupalgorithmictext[\s!en][endif=end if] +\setupalgorithmictext[\s!en][for=for] +\setupalgorithmictext[\s!en][forall=for all] +\setupalgorithmictext[\s!en][do=do] +\setupalgorithmictext[\s!en][endfor=end for] +\setupalgorithmictext[\s!en][while=while] +\setupalgorithmictext[\s!en][endwhile=end while] +\setupalgorithmictext[\s!en][loop=loop] +\setupalgorithmictext[\s!en][endloop=end loop] +\setupalgorithmictext[\s!en][repeat=repeat] +\setupalgorithmictext[\s!en][until=until] +\setupalgorithmictext[\s!en][print=print] +\setupalgorithmictext[\s!en][return=return] +\setupalgorithmictext[\s!en][true=true] +\setupalgorithmictext[\s!en][false=false] + +% Default values + +\definealgorithmic[\v!algorithmic] + +\setupalgorithmic + [ \c!numbering=\v!no, % linenumbering + \c!conversion=\v!numbers, % linenumbering + \c!start=1, % linenumbering + \c!step=1, % linenumbering + \c!method=\v!first, % linenumbering + \c!continue=\v!no, % linenumbering + \c!location=\v!left, % linenumbering + \c!numberstyle=, % linenumbering + \c!numbercolor=, % linenumbering + \c!numberwidth=2em, % linenumbering + \c!align=\v!auto, % linenumbering + \c!width=1em, + \c!margin=1em, + \c!labelstyle=\v!bold, + \c!before=, + \c!after=, + \c!spacebefore=\v!line, + \c!spaceafter=\v!line] + +\protect \endinput |