blob: 988457837dcaa374f5ab56f65434ee94677c5018 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
%% This is part of OpTeX project, see http://petr.olsak.net/optex
\_codedecl \sdef {Basic macros for OpTeX <2019-05-21>}
\let\_bgroup={ \let\_egroup=}
\_bgroup \_lccode`\.=`\\ \_lowercase{\_egroup \_def\_nbackslash {.}}
\_def\_empty {}
\_def\_wlog {\_immediate\_write-1 } % write on log file (only)
\_def\_sdef #1{\_ea\_def \_csname#1\_endcsname}
\_def\_sxdef #1{\_ea\_xdef \_csname#1\_endcsname}
\_def\_slet#1#2{\_ea\_let \_csname#1\_ea\_endcsname \_csname#2\_endcsname}
\_def\_adef#1{\_catcode`#1=13 \_begingroup \_lccode`\~=`#1\_lowercase{\_endgroup\_def~}}
\_def\_cs #1{\_csname#1\_endcsname}
\_long\_def \_addto #1#2{\_ea\_def\_ea#1\_ea{#1#2}}
\_ea\_def \_ea\_meaningsepare \_ea#\_ea1\_string m#2:#3->#4^{{#1}{#3}{#4}}
\_long\_def\_isinlist #1#2#3{% \isinlist \list{word}\iftrue
\_long\_def\_isinlistA ##1#2##2\_end{%
\_def\_isinlistA {##2}%
\_unless\_ifx\_isinlistA\_empty
}%
\_ea \_isinlistA #1\_endlistsep#2\_end
}
\_bgroup \_catcode`!=3 \_catcode`?=3
\_gdef\_replstring #1#2#3{% \replstring #1{stringA}{stringB}
\_long\_def\_replacestringsA##1#2{\_def #1{##1}\_replacestringsB}%
\_long\_def\_replacestringsB##1#2{\_ifx!##1\_relax \_else \_addto #1{#3##1}%
\_ea\_replacestringsB\_fi}%
\_ea\_replacestringsA #1?#2!#2%
\_long\_def\_replacestringsA##1?{\_def #1{##1}}\_ea\_replacestringsA #1}
\_egroup
\_def\_loggingall{\_tracingcommands=3 \tracingstats=2 \tracingassigns=1
\tracingpages=1 \tracingoutput=1 \tracinglostchars=1
\tracingmacros=2 \tracingparagraphs=1 \tracingrestores=1 }
\_def\_tracingall{\tracingonline=1 \loggingall}
\_public
\bgroup \egroup \nbackslash \sdef \sxdef \slet \adef
\addto \meaningsepare \wlog \empty
\isinlist \replstring \loggingall \tracingall ;
\_endcode % -------------------------------------
|