-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.tex
40 lines (37 loc) · 1.21 KB
/
program.tex
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
% to start every program, allows to define a rule composition with a name (#1) and rule-definitions (#2)
% afterwards you get \#1 to run the program with a constraint list name
% note: your name (#1) must be a valid command sequence to work!
\long\def\chr@program#1#2{\begingroup
\edef\chr@current{#1}%
\let\makelist=\chr@list
\let\listequal=\chr@list@equal
\let\printlist=\chr@list@print
\let\compose=\chr@compose
\let\permute=\chr@permute
\let\match=\chr@match
\let\rule=\chr@rule
\let\body=\chr@body
\let\ebody=\chr@ebody
\let\run=\chr@run
\let\log=\chr@log
\let\true=\chr@true
\let\false=\chr@false
% TODO: find better name :D
\let\Rule=\chr@rule@inline
\let\Compose=\chr@compose@inline
\let\Run=\chr@run@inline
\let\LimitCycles=\chr@limitcycles
\let\enablelog=\chr@enable@log
\chr@list{chr@constraints}{}%
% list of rules for the current program
\chr@list{chr@rules}{}%
\ignorespaces#2\relax
\endgroup
}
\def\chr@limitcycles#1{%
\def\chr@maxruncycles{#1}%
}
% program-scoped setter and getter
\def\chr@program@set#1{\expandafter\def\csname chr@\chr@current @#1\endcsname}
\def\chr@program@get#1{\csname chr@\chr@current @#1\endcsname}
\let\chr\chr@program