-
Notifications
You must be signed in to change notification settings - Fork 0
/
hisyntax-scheme.opm
73 lines (68 loc) · 2.5 KB
/
hisyntax-scheme.opm
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
%% This is edited from hisyntax-python
\_codedecl \_hisyntaxscheme {Syntax highlighting for Scheme sources <2020-04-04>}
\_newtoks \_hisyntaxscheme \_newtoks \_hicolorsscheme
\_global\_hicolorsscheme={% colors for Scheme language
\_colordef \MediumBlue {.5\LightBlue + .5\Blue}
\_hicolor M \Orange % Multi line strings
\_hicolor S \Red % Single line strings
\_hicolor C \Green % Comments
\_hicolor K \MediumBlue % Keywords
\_hicolor O \Black % Operators
\_hicolor N \Black % Numbers
\_hicolor U \DarkGrey % Outputs
}
\_global\_hisyntaxscheme={%
\_the\_hicolorsscheme
\_let\s=\_relax \_let\c=\_relax \_let\e=\_relax \_let\o=\_relax
\_replthis{\_string\"}{{\_string\"}} % protect \", \'
\_replthis{\_string\'}{{\_string\'}}
%
\_replfromto{\n;Value:\n\ \n}{^^J}{\z U{\sltt#1\smallskip}^^J} % outputs
\_replfromto{\n;value:\n\ \n}{^^J}{\z U{\sltt#1}^^J} % outputs
\_replfromto{\n;Display:\n\ \n}{^^J}{\z C{#1}^^J} % displays
\_replfromto{\_string;}{^^J}{\z C{;#1}^^J} % comments
%
\_replthis{"}{\_noexpand\_hipystr2{"}S}
\_replthis{'}{\_noexpand\_hipystr3{'}S}
\_edef\_tmpb{\_tmpb} % realize string marks
%
\_foreach {br}{Br}{bR}{BR}{rb}{rB}{Rb}{RB}uUrRbB % string prefixes
\_do {\_replthis{#1\s}{\_noexpand\_hipystrpre#1}}
\_def\s{}
\_edef\_tmpb{\_tmpb}
%
\_edef \_tmpa {()}
\_ea\_foreach \_tmpa
\_do {\_replthis{#1}{\n\o#1\n}}
%
\_foreach % keywords
{and}{if}{else}{cond}{lambda}{or}{define}{let}
\_do {\_replthis{\n#1\n}{\z K{#1}}}
%
\_foreach
{\_string#t}{\_string#f}
\_do {\_replthis{\n#1\n}{\z N{#1}}}
%
\_foreach 0123456789 % numbers
\_do {\_replfromto{\n#1}{\n}{\c#1##1\e}}
%
\_replthis{\e\o.\c}{.}
\_replthis{\e\o.\n}{.\e}
\_replthis{\n\o.\c}{\c.}
\_replthis{e\e\o+\c}{e+}\_replthis{e\e\o-\c}{e-}
\_replthis{E\e\o+\c}{E+}\_replthis{E\e\o-\c}{E-}
\_replthis{\e j}{j\e}
%
%
\_def\o#1{\z O{#1}}
\_def\c#1\e{\z N{#1}}
}
\_gdef\_hipystr#1#2#3#4\_hipystr#5#6#7{%
\_ifx#1#5\s\x#3{#2#4#2}%
\_else \_afterfi{\_hipystr#1{#2}#3#4#6}\_fi
}
\_gdef\_hipystrpre#1\x#2{\x#2{#1}\x#2}
\_ifx\LightBlue\_undefined \_gdef\LightBlue {\_setcmykcolor{1 .43 0 0}}\_fi
\_ifx\Orange\_undefined \_gdef\Orange {\_setcmykcolor{0 .64 1 0}}\_fi
\_ifx\DarkGrey\_undefined \_gdef\DarkGrey {\setgreycolor{.3}}\_fi
\_endcode %------------------------------------------------