blob: 95432a86ef306e81aa3b0ebf035ce9575d2db3d7 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
%% Syntax functions
\addassoc\@globalenv\quote{\@tlabel@quote{}}%
\addassoc\@globalenv\lambda{\@tlabel@lambda{}}
\addassoc\@globalenv\define{\@tlabel@define{}}
\addassoc\@globalenv\lispif{\@tlabel@if{}}
\addassoc\@globalenv\defmacro{\@tlabel@defmacro{}}
\addassoc\@globalenv\begin{\@tlabel@begin{}}
\addassoc\@globalenv\defineM{\@tlabel@mdefine{}}
\addassoc\@globalenv\setB{\@tlabel@setb{}}
\addassoc\@globalenv\@let{\@tlabel@@let{}}
\addassoc\@globalenv\@mlet{\@tlabel@@mlet{}}
\addassoc\@globalenv\macroexpand{\@tlabel@macroexpand{}}
\addassoc\@globalenv\car{\@tlabel@func{\@get@car}}
\addassoc\@globalenv\cdr{\@tlabel@func{\@get@cdr}}
\addassoc\@globalenv\cons{\@tlabel@func{\@make@cons}}
\newcount\@temp@count
\addassoc\@globalenv\length{\@temp@count0\relax\@tlabel@func{\@lisp@length}}
\def\@lisp@length#1#2#3{%
\ifx#2\@tlabel@nil
\expandafter\gdef\expandafter#1%
\expandafter{\expandafter\@tlabel@int\expandafter{\the\@temp@count}}%
\let\@length@next\@length@gobble
\else\ifx#2\@tlabel@cons
\advance\@temp@count1\relax
\let\@length@next\@@lisp@length
\else
\errmessage{LISP on TeX [function--length]: The Argument must be a LIST}%
\fi\fi\@length@next#3}
\def\@length@gobble#1{}
\def\@@lisp@length#1#2#3{\expandafter\@lisp@length#3}
%equality
\addassoc\@globalenv\={\@tlabel@func{\@lisp@equal}}
\def\@lisp@equal#1#2#3#4#5{%
\gdef#1{\@tlabel@bool{f}}%
\ifx#2#4%
\def\@@temp@eqchecki{#3}%
\def\@@temp@eqcheckii{#5}%
\ifx\@@temp@eqchecki\@@temp@eqcheckii\gdef#1{\@tlabel@bool{t}}\fi
\fi}
% printing function
\addassoc\@globalenv\print{\@tlabel@func{\@tex@print}}
\def\@tex@print#1{\gdef#1{\@tlabel@nil{}}\@tex@print@}
\def\@tex@print@#1#2{%
\ifx#1\@tlabel@int
\@add@to@write@buffer\@temp@write@buffer{:#2}%
\else\ifx#1\@tlabel@symbol
\@add@to@write@buffer\@temp@write@buffer{\string#2}%
\else\ifx#1\@tlabel@string
\@add@to@write@buffer\@temp@write@buffer{'#2'}%
\else\ifx#1\@tlabel@bool
\@add@to@write@buffer\@temp@write@buffer{/#2}%
\else\ifx#1\@tlabel@dimen
\@add@to@write@buffer\@temp@write@buffer{!#2}%
\else\ifx#1\@tlabel@skip
\@add@to@write@buffer\@temp@write@buffer{@#2}%
\else\ifx#1\@tlabel@nil
\@add@to@write@buffer\@temp@write@buffer{()}%
\else\ifx#1\@tlabel@cons
\@add@to@write@buffer\@temp@write@buffer{(}%
\@tex@print@cell#2%
\else
\@add@to@write@buffer\@temp@write@buffer{[INNER]}%
\fi\fi\fi\fi\fi\fi\fi\fi}
\def\@tex@print@cell#1#2{%
\expandafter\@tex@print@#1%
\expandafter\@tex@print@cdr#2}
\def\@tex@print@cdr#1#2{%
\ifx#1\@tlabel@cons
\@add@to@write@buffer\@temp@write@buffer{ }%
\@tex@print@cell#2%
\else\ifx#1\@tlabel@nil
\@add@to@write@buffer\@temp@write@buffer{)}%
\else
\@add@to@write@buffer\@temp@write@buffer{.}%
\@tex@print@#1{#2}%
\@add@to@write@buffer\@temp@write@buffer{)}%
\fi\fi}
\addassoc\@globalenv\texprint{\@tlabel@func{\@tex@texprint}}
\def\@tex@texprint#1#2#3{%
\gdef#1{\@tlabel@nil{}}\@@tex@texprint#2{#3}}
\def\@@tex@texprint#1#2{%
\ifx#1\@tlabel@string
\@add@to@write@buffer\@temp@write@buffer{#2}%
\else\ifx#1\@tlabel@int
\@add@to@write@buffer\@temp@write@buffer{#2}%
\else
\@add@to@write@buffer\@temp@write@buffer{INNER TOKEN}%
\fi\fi}
\addassoc\@globalenv\stdprint{\@tlabel@func{\@tex@stdprint}}
\def\@tex@stdprint#1#2#3{%
\gdef#1{\@tlabel@nil{}}%
\let\@save@write@buffer\@temp@write@buffer
\def\@temp@write@buffer{}%
\@tex@print@#2{#3}%
\toks0\expandafter{\@temp@write@buffer}%
\immediate\write16{\the\toks0}%
\let\@temp@write@buffer\@save@write@buffer}
% Type predicates
\def\@type@pred@add#1{\expandafter\@@type@pred@add\expandafter#1}
\def\@@type@pred@add#1#2{\addassoc\@globalenv#1{\@tlabel@func{#2}}}
\def\@type@pred@define#1{\expandafter\@@type@pred@define\expandafter#1}
\def\@@type@pred@define#1#2{%
\def#1##1##2##3{\ifx##2#2\gdef##1{\@tlabel@bool{t}}\else\gdef##1{\@tlabel@bool{f}}\fi}}
\def\@type@addassoc{\addassoc\@globalenv}
\@for\@type:=\@defined@datatype\do{%
\expandafter\@type@pred@add\csname\@type Q\endcsname\csname @type@\@type\endcsname
\expandafter\@type@pred@define\csname @type@\@type\endcsname\csname @tlabel@\@type\endcsname}
\addassoc\@globalenv\pairQ{\@tlabel@func{\@type@cons}}
\addassoc\@globalenv\booleanQ{\@tlabel@func{\@type@bool}}
% eval , apply
\addassoc\@globalenv\eval{\@tlabel@envfunc{\@extern@eval}}
\def\@extern@eval#1#2#3#4{\@eval#3{#4}{#2}#1}
\addassoc\@globalenv\apply{\@tlabel@envfunc{\@extern@apply}}
\def\@extern@apply#1#2#3#4#5#6{% reg, env, labelfun, contfun, labellist, contlist
\def\@lisp@apply@temp{}% init
\@flatten@args#5{#6}\@lisp@apply@temp
\expandafter\@extern@apply@next\expandafter{\@lisp@apply@temp}#3{#4}{#2}#1}
\def\@extern@apply@next#1#2#3#4#5{% arglist-flatten, labelfun, contfun env, reg
{\expandafter\@@select@@apply#2{#3}#1\@{#4}#5}}
% values
%\addassoc\@globalenv\values{\@tlabel@func{\@lisp@multivalues}}
%\def\@lisp@multivalues#1#2\relax{\gdef#1{#2}}
% read
\addassoc\@globalenv\read{\@tlabel@func{\@lisp@read@stdin}}
\def\@lisp@read@stdin#1{%
\read-1 to#1%
\def\@lisp@read@stdin@callback##1##2{%
\gdef#1{##1{##2}}}%
\expandafter\@lispread\expandafter\@lisp@read@stdin@callback#1}
|