summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-mod-fpnum.sty
blob: 291b343baa3a517c90f5b020c4458c940e059c5f (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
%%% module name :: fpnum

% regist type and gc 
\ifx\@defined@additional@type\@empty
  \def\@defined@additional@type{fpnum}%
\else
  \edef\@defined@additional@type{\@defined@additional@type,fpnum}%
\fi
\let\@lisp@gc@trace@fpnum\@gobble

\def\@mod@read@fpnum#1#2{\gdef#1{\@tlabel@fpnum{#2}}}
\def\@tlabel@fpnum{\@eval@fpnum\@apply@fpnum\@@apply@fpnum}

\def\@eval@fpnum#1#2#3{\gdef#3{\@tlabel@fpnum{#1}}} % #1 contents, #2 environment, #3 register
\def\@apply@fpnum{\errmessage{LISP on TeX [internal apply, module fpnum] cannot apply}}
\def\@@apply@fpnum{\errmessage{LISP on TeX [function --- apply, module fpnum] cannot apply}}

\newdimen\@tempdimeni
\newdimen\@tempdimenii

\@lisp@env@add@global\fpnumTOstring{\@tlabel@func{\@lisp@func@check@args{1}{\@mod@fpnum@tostring}}}
%TODO: error handling
\def\@mod@fpnum@tostring#1\@tlabel@fpnum#2{\gdef#1{\@tlabel@string{#2}}}

\@lisp@env@add@global\fpplus{\@tlabel@func{\@lisp@func@check@args{*}{\@tempdimeni0pt\relax\@mod@fpnum@plus}}}
%TODO: error handling
\def\@mod@fpnum@plus#1#2#3{%
	\ifx#2\relax
		\let\@next@fpnum@plus\@@fin@fpnum@plus
	\else\ifx#2\@tlabel@fpnum
		\advance\@tempdimeni#3pt\relax
		\let\@next@fpnum@plus\@mod@fpnum@plus
	\else
		\errmessage{LISP on TeX [fpnum --- plus]: Invalid argument}%
	\fi\fi\@next@fpnum@plus#1}
\def\@@fin@fpnum@plus#1{\xdef#1{\noexpand\@tlabel@fpnum{\strip@pt\@tempdimeni}}}

\@lisp@env@add@global\fpmul{\@tlabel@func{\@lisp@func@check@args{*}{\@tempdimeni1pt\relax\@mod@fpnum@mul}}}
%TODO: error handling
\def\@mod@fpnum@mul#1#2#3{%
	\ifx#2\relax
		\let\@next@fpnum@mul\@@fin@fpnum@mul
	\else\ifx#2\@tlabel@fpnum
		\@tempdimeni#3\@tempdimeni
		\let\@next@fpnum@mul\@mod@fpnum@mul
	\else
		\errmessage{LISP on TeX [fpnum --- mul]: Invalid argument}%
	\fi\fi\@next@fpnum@mul#1}
\def\@@fin@fpnum@mul#1{\xdef#1{\noexpand\@tlabel@fpnum{\strip@pt\@tempdimeni}}}

\@lisp@env@add@global\fpminus{\@tlabel@func{\@lisp@func@check@args{+}{\@mod@fpnum@minus}}}
\def\@mod@fpnum@minus#1#2#3#4#5{%
	\ifx#4\relax
		\ifx#2\@tlabel@fpnum
			\@tempdimenii#3pt
			\@tempdimeni0pt
			\advance\@tempdimeni-\@tempdimenii
			\let\@next@fpnum@minus\@@fin@fpnum@minus
		\else
			\errmessage{LISP on TeX [fpnum --- minus]: Invalid argument}%
		\fi
	\else\ifx#4\@tlabel@fpnum
		\ifx#2\@tlabel@fpnum
			\@tempdimeni#3pt
			\let\@next@fpnum@minus\@@next@fpnum@minus
		\else
			\errmessage{LISP on TeX [fpnum --- minus]: Invalid argument}%
		\fi
	\else
		\errmessage{LISP on TeX [fpnum --- minus]: Invalid argument}%
	\fi\fi
	\@next@fpnum@minus#1#4{#5}}
\def\@@fin@fpnum@minus#1{\xdef#1{\noexpand\@tlabel@fpnum{\strip@pt\@tempdimeni}}}
\def\@@next@fpnum@minus#1#2#3{%
	\ifx#2\relax
		\let\@next@fpnum@minus\@@fin@fpnum@minus
	\else\ifx#2\@tlabel@fpnum
		\@tempdimenii#3pt
		\advance\@tempdimeni-\@tempdimenii
		\let\@next@fpnum@minus\@@next@fpnum@minus
	\else
		\errmessage{LISP on TeX [fpnum --- minus]: Invalid argument}%
	\fi\fi
	\@next@fpnum@minus#1}

\@lisp@env@add@global\fplt{\@tlabel@func{\@lisp@func@check@args{2}{\@mod@fpnum@lt}}}
\def\@mod@fpnum@lt#1\@tlabel@fpnum#2\@tlabel@fpnum#3{%
	\ifdim#2pt<#3pt
		\gdef#1{\@tlabel@bool{t}}%
	\else
		\gdef#1{\@tlabel@bool{f}}%
	\fi
}